Capturing HTTP Cookies in a POST Response and Sending in Subsequent HTTP POST’s

Question: A particular REST/Web API returns a cookie. I need to capture this cookie and use it when sending subsequent POSTs. For example, this is the CURL statement to login and save the response cookie(s) to a file. curl -c cookies.txt -H “Content-Type: application/json” -X POST -d ‘{“username”:”user”,”password”:”pass”}’ http://192.168.1.1/api/login Then I need to use the cookie when sending an SMS […]

Calling a REST POST API and Parsing JSON/XML Response

This blog post describes a general procedure for writing code that calls an HTTP/HTTPS POST REST API and parses the JSON or XML response. Step 1: Form the CURL Command A POST request in the form of a CURL command will look like this: curl -X POST https://test-api.service.hmrc.gov.uk/organisations/vat/123456789/returns \ -H “Accept: application/vnd.hmrc.1.0+json” \ -H “Content-Type: application/json” \ -H “Authorization: Bearer […]

Equivalent HTML Form and Chilkat HTTP POST

Any HTML form POST can be duplicated programmatically with the Chilkat HTTP component. As an example, consider this HTML: <html> <body> <form name=”input” action=”http://www.chilkatsoft.com/testPostHandler.asp” method=”post”> Arg1: <input type=”text” name=”arg1″> <br>(Arg2 is a hidden input)<br> <input type=”hidden” name=”arg2″ value=”abc123″> Arg3 <input type=”text” name=”arg3″> <input type=”submit” value=”Submit”> </form> </body> </html> It submits a POST to http://www.chilkatsoft.com/testPostHandler.asp. The ASP that receives the post […]