HTTP PUT - string data for update

How would I translate instructions showing an example using curl for an HTTP PUT using HTTPSocket.SendRequest ( Method as String,URL as String, Timeout as Integer ) As String. Here is the example using curl I was provided in the API documentation:

curl -X PUT \\ -d "order[status]=S" https://domainname.com/something/orders/API_IDnumber

I cannot find any example on how to include the string “order[status]=S”. The requirement to provide this order status update is to do a PUT. If I were going to do a POST I would do it something like the following:

[code] Dim socket As New HTTPSocket
Dim updatestring,urlstring,r,e As String

updatestring = “order[status]=S”
urlstring = “https://domainname.com/something/orders/123456789
updatestring = DefineEncoding(updatestring,Encodings.UTF8)
socket.SetPostContent(updatestring,"")
r = socket.Post(urlstring,30)
e = RemoteTrigger.HTTPStatusCode

MsgBox Str(e) + ", " + r
[/code]

POST is a defined method with example code but PUT example code is eluding me.

[code]Dim postData as String
Dim html as String
Dim url as String = “https://domainname.com/something/orders/123456789

Dim http as new HTTPSecureSocket // the link starts with https, so you need to use HTTPSecureSocket instead of HTTPSocket

postData = “order[status]=S”

http.SetRequestContent(postData,“application/x-www-form-urlencoded”)

html = http.SendRequest(“PUT”,url,30)[/code]

The above code should work. Sending a PUT request is easy!

Also, you could play around with HTTPSocket and this website: httpbin.org if you wanna try some more HTTP requests!

Thanks Ashot! That was a quick reply. I figured it would be something simple. The HTTPSecureSocket.SetRequestContent was what I was missing.

One more question. I get this response back <error>Access not permitted</error> so I presume I need to authenticate. How is that normally done?

It depends on the api.