Hi Guys and Gals,
I have developed some VBA code using the MSXML2.ServerXMLHTTP object to request data over a API. Using "GET" the code returns a JSON string which I then break down and save in a table.
Now I want to be able to use "PUT" to update a field in a particular record over the API. I have provided some concatenated code below...
Using GET:
'lsRequest = "http://localhost:8080/xxxxxxxxx/xxxxxxxxxxx/Contact/Customer/?api-version=v2"
With objXMLRequest
.Open "GET", lsRequest, False
' need to do basic authentication
' acknowledgement to http://pastie.org/1192157
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Basic " + Base64Encode(lsCFUsername + ":" + lsCFPassword)
.Send
byteData = .responsebody
End with
Now I need to use "PUT" to update a record...
Using PUT:
'lsRequest = "http://localhost:8080/xxxxxxxxx/xxxxxxxxxxx/Contact/Customer/?api-version=v2"
'lsData = "{""....""}" ?
With objXMLRequest
.Open "PUT", lsRequest, False
' need to do basic authentication
' acknowledgement to http://pastie.org/1192157
.setRequestHeader "Content-Type", "application/json"
.setRequestHeader "Accept", "application/json"
.setRequestHeader "Authorization", "Basic " + Base64Encode(lsCFUsername + ":" + lsCFPassword)
.Send (lsData)
byteData = .responsebody
End with
So, my questions are:
1. Do I need to specify the particular record I want to update in the lsRequest string (i.e. "http://localhost:8080/xxxxxxxxx/xxxxxxxxxxx/Contact/Customer/?&Filter="UID%20eq%20xxxxxxxx&api-version=v2") and then lsData = "{""IsActive"":"True"}" to update the IsActive field?... or
2. Should lsRequest remain "http://localhost:8080/xxxxxxxxx/xxxxxxxxxxx/Contact/Customer/?api-version=v2" and I put the ID and the updated field in the lsData string (i.e. "{""UID"":""xxxxxxx"",""IsActive"":"True"}"?
Thanks in advance!
Mitch