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 […]

How to Send application/x-www-form-urlencoded POST to a URL with some Params

Question I need to get a token: URL TEST : “https://apitest.dtes.mh.gob.sv/seguridad/auth” Method : POST Parameters Headers Content-type : application/x-www-form-urlencoded Body user (string) pwd (string) Answer See the online tutorial explaining common HTTP requests at Format of Common HTTP Requests. Specifically, look here: https://www.chilkatsoft.com/http_post_url_encoded.asp

HTTP “broken pipe” Error on non-Windows Systems (Linux, iOS, MacOSX, etc.)

If you see the error lines “The connection already exists, as far as we know..” followed by “socketError: Broken pipe”  in any LastErrorText for a method that sends an HTTP request, it means the following:   The server replied to the previous request without a “Connection: close” header, thus allowing the client to keep the connection open for the next request.  […]

Progress Monitoring HTTP Requests in Installed Apps

This is a note about the pitfalls of progress monitoring HTTP requests sent from an installed app (i.e. not web app running in a browser). Ideally, we’d like to know how long an HTTP POST is going to take, and update the percent-completed visually so that when it reaches 100% the operation is neatly finished as indicated.  This turns out […]

Chilkat HTTP Methods that return an HttpResponse Object

Question: I am having a problem identifying read timeouts from sites. I set ConnectTimeout and ReadTimeout properties of the HTTP object. When the site fails to respond within ReadTimeout, the following happens: PText still returns 0 PText returns a response object Reading of StatusCode and StatusText properties of the response object is successful Reading of BodyStr property of the response […]

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 […]

HTTP Upload vs. SOAP Request (how they are different)

What is the difference between an HTTP Upload and a SOAP Request? An upload is an HTTP request that uses the multipart/form-data content-type. (All HTTP requests and responses are MIME, and the format of a given request is determined by the content-type.) A SOAP request, on the other hand, has a content-type of text/xml, which means it is composed of […]