wwHTTP::Put

Uses an HTTP PUT operation to post content to the server and to retrieve Web content from a URL.

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

*** post HTML form variables
loHttp.AddPostKey("Name","Rick")
loHttp.AddPostKey("Value","1")

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


lcJson = loApp.GetRequestJson()  && some method that gets data

*** Prefer to recreate wwHttp
loHttp = CREATEOBJECT("wwHttp")

*** post raw data buffer (JSON in this case)
loHttp.cContentType="application/json"
loHttp.AddPostKey(lcJson)

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

PUT is similar to POST but semantically used for updates, while POST is semantically used for additions in REST APIs

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

o.Put(lcUrl, lcUserName, lcPassword, 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.

Parameters

lcUrl
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: http://www.west-wind.com/wwipstuff.asp

lcUserName
Optional - Username used for Basic Authentication

lcPassword
Optional - Password used for Basic Authentication

lcFileName
An optional path into which to download the content into. 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

© West Wind Technologies, 2023 • Updated: 02/06/19
Comment or report problem with topic