POST: sending a post request in a url itself

前端 未结 7 1216
忘掉有多难
忘掉有多难 2020-12-24 12:46

I have been given a url .. www.abc.com/details and asked to send my name and phone number on this url using POST. They have told me to set the cont

7条回答
  •  伪装坚强ぢ
    2020-12-24 13:01

    Based on what you provided, it is pretty simple for what you need to do and you even have a number of ways to go about doing it. You'll need something that'll let you post a body with your request. Almost any programming language can do this as well as command line tools like cURL.

    One you have your tool decided, you'll need to create your JSON body and submit it to the server.

    An example using cURL would be (all in one line, minus the \ at the end of the first line):

    curl -v -H "Content-Type: application/json" -X POST \
         -d '{"name":"your name","phonenumber":"111-111"}' http://www.abc.com/details
    

    The above command will create a request that should look like the following:

    POST /details HTTP/1.1
    Host: www.abc.com
    Content-Type: application/json
    Content-Length: 44
    
    {"name":"your name","phonenumber":"111-111"}
    

提交回复
热议问题