Just FYI I’ve uploaded new versions which create different code for each of the body types. For instance, if the body type is set to JSON, you get code for a JSONItem on the old framework and for a Xojo.Core.Dictionary converted to Text and then to a Xojo.Core.MemoryBlock on the new framework.
Old Framework
[code]// My API
// Set up the socket
dim h as new HTTPSocket
h.setRequestHeader(“myHeader”,“Header Value”)
h.setRequestHeader(“Content-Type”,“application/json”)
// JSON
Dim js As New JSONItem
js.Value(“age”) = 105
js.Value(“registered”) = true
js.Value(“favorite”) = nil
js.Value(“name”) = “Mickey Mouse”
// Convert Dictionary to JSON Text
Dim data As String = js.toString()
// Assign to the Request’s Content
h.SetRequestContent(data,“application/json”)
// Set the URL
dim url as string = “http://echo.luckymarmot.com”
// Send Synchronous Request
dim s as string = h.SendRequest(“GET”,url,30)[/code]
New Framework
[code]// My API
// Set up the socket
// “mySocket” should be a property stored elsewhere so it will not go out of scope
mySocket = new Xojo.Net.HTTPSocket
mySocket.RequestHeader(“myHeader”) = “Header Value”
mySocket.RequestHeader(“Content-Type”) = “application/json”
// JSON
Dim d As New Dictionary
d.Value(“age”) = 105
d.Value(“registered”) = true
d.Value(“favorite”) = nil
d.Value(“name”) = “Mickey Mouse”
// Convert Dictionary to JSON Text
Dim json As Text = Xojo.Data.GenerateJSON(d)
// Convert Text to Memoryblock
Dim data As Xojo.Core.MemoryBlock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(json)
// Assign to the Request’s Content
mySocket.SetRequestContent(data,“application/json”)
// Set the URL
dim url as Text = “http://echo.luckymarmot.com”
// Send Asynchronous Request
mySocket.Send(“GET”,url)[/code]