Making a http POST request using Arduino

后端 未结 4 1345
深忆病人
深忆病人 2020-12-13 02:55

I am trying to post information to an API on a web project that I have created and hosted. I am not sure what the exact format is for the HTTP POST request. Every time I t

4条回答
  •  旧时难觅i
    2020-12-13 03:28

    Sending hand-crafted HTTP packets can be a bit tricky because they are extremely picky about the format used. I highly recommend reading through the HTTP protocol if you have the time because it explains the syntax and fields required. In particular you should look at section 5 "Request".

    With regards to your code, you do need to specify the HTTP version after the POST URI and I believe you also need to specify the "Host" header. On top of that you need to be sure to have a carriage-return line-feed (CRLF) at the end of each line. So, your packet should look something like:

    POST /Api/AddParking/3 HTTP/1.1
    Host: www.yourhost.com
    

提交回复
热议问题