Uses an HTTP POST operation to post content to the server and to retrieve Web content from a URL. You can pass in a URL and the raw Post data to send. Make sure to set .cContentType if using non-form data.

DO wwHttp
LOCAL loHttp as wwHttp OF wwhttp.prg
loHttp = CREATEOBJECT("wwHttp")

*** Post HTML Form Variables
* loHttp.cContentType="application/x-www-form-urlencoded"  && default for POST
lcHTML = loHttp.Post("https://yoursite.com/some/endpoint")

*** POST a JSON request to a server
lcJson = [{"name": "Rick", "company": "West Wind", "entered": "2020-10-21T08:12:33Z"}]

*** Recreate wwHttp (best practice)
loHttp = CREATEOBJECT("wwHttp")

*** Post a raw Buffer of data

lcHTML = loHttp.Post("https://yoursite.com/some/json/endpoint")

JSON Service Requests using wwJsonServiceClient

If you're sending data to JSON REST Services you can simplify the JSON serialization and HTTP calls using the wwJsonServiceClient class which lets simply pass and receive objects and values rather than serialized strings.

Please also see wwHttp::HttpGet and Access Http Content over the Web

o.Post(lcUrl, lcPostData, lcOutputFile)

Return Value

String - HTTP result, which most likely will be HTML, but can be whatever data the link returns. This includes XML and binary data like Word documents or even data files. On error this string will be blank and the nError and cErrorMsg properties will be set.


The full URL you want to retrieve. This URL must include the protocol (HTTP or HTTPS for example) and the Domain Name or IP Address. Example: https://west-wind.com/default.aspx

Optional - Optional raw post buffer to send to the server - overrides any other post data you might have added with AddPostKey(). Make sure you set the .cContentType with the type of the data you are sending like application/json.

Optional - A filename into which to download the result content into. This allows you to download large content including greater than 16mb directly into a file. If this parameter is used the return value from this method will always return blank and only the file is created on success. To check for errors, check the nError/cErrorMsg and the cResultCode properties.

See also:

Class wwHTTP | wwHttp::HttpGet | Class wwJsonServiceClient

© West Wind Technologies, 2020 • Updated: 10/23/20
Comment or report problem with topic