Hi,
I adapted the methods used in httputils to also work with PUT, DELETE etc. However, I face some problems with json payloads and PUT statements.
When using below JSON it gives me "Could not parse invalid json":
{
"field1":"test"
}
This is what I do:
jsonMap.Put ("field1","test")
jsonList.Add (jsonMap)
json.Initialize2 (jsonList)
jsonData = json.ToPrettyString(2)
jsonData = jsonData.Replace ("[","")
jsonData = jsonData.Replace ("]","")
httpPUT.Initialize ("httpPUTResult",Me)
httpPUT.PutString ("some api url",jsonData)
httpPUT.GetRequest.SetContentType("application/json")
HTTPUtils method
Public Sub PutString(Link As String, Text As String)
PutBytes(Link, Text.GetBytes("UTF8"))
End Sub
Public Sub PutBytes(Link As String, Data() As Byte)
req.InitializePut2(Link, Data)
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
I cannot share the API I use but it is a default REST interface that works with PUT and DELETE.
I adapted the methods used in httputils to also work with PUT, DELETE etc. However, I face some problems with json payloads and PUT statements.
When using below JSON it gives me "Could not parse invalid json":
{
"field1":"test"
}
This is what I do:
jsonMap.Put ("field1","test")
jsonList.Add (jsonMap)
json.Initialize2 (jsonList)
jsonData = json.ToPrettyString(2)
jsonData = jsonData.Replace ("[","")
jsonData = jsonData.Replace ("]","")
httpPUT.Initialize ("httpPUTResult",Me)
httpPUT.PutString ("some api url",jsonData)
httpPUT.GetRequest.SetContentType("application/json")
HTTPUtils method
Public Sub PutString(Link As String, Text As String)
PutBytes(Link, Text.GetBytes("UTF8"))
End Sub
Public Sub PutBytes(Link As String, Data() As Byte)
req.InitializePut2(Link, Data)
CallSubDelayed2(HttpUtils2Service, "SubmitJob", Me)
End Sub
I cannot share the API I use but it is a default REST interface that works with PUT and DELETE.