How to send a header using a HTTP request through a curl call?

后端 未结 10 1392
梦如初夏
梦如初夏 2020-11-22 16:45

I wish to send a header to my Apache server on a Linux box. How can I achieve this via a curl call?

10条回答
  •  不知归路
    2020-11-22 17:32

    You can also send multiple headers, data (JSON for example), and specify Call method (POST,GET) into a single CUrl call like this:

    curl -X POST(Get or whatever) \
      http://your_url.com/api/endpoint \
      -H 'Content-Type: application/json' \
      -H 'header-element1: header-data1' \
      -H 'header-element2: header-data2' \
    

    ......more headers................

      -d '{
      "JsonExArray": [
        {
          "json_prop": "1",
        },
        {
          "json_prop": "2",
        }
      ]
    }'
    

提交回复
热议问题