Posting JSON to a c# REST Web Service

LollyNET247

Member
Licensed User
Longtime User
Hi everyone,
I apologise for being probably the 100th person for asking a dumb, or repetitve question; but does anyone know if this is the right way to post JSON to a restful web service?

Dim req As HttpRequest
Dim hc As HttpClient
hc.Initialize("hc")

Dim Data As List
Data.Initialize
Data.Add("2,Sausages and chips,Make it nice,10")
Data.Add("5,Coke,,10")
Dim JSONGenerator1 As JSONGenerator
JSONGenerator1.Initialize2(Data)
req.InitializePost2("http://10.0.2.2:50579/Service1.svc", JSONGenerator1.ToPrettyString(2).GetBytes("UTF8"))


Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
..
End Sub

Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
..
End Sub

As usual, I really appreciate all of your assistance!
Regards,
Laurence
 

LollyNET247

Member
Licensed User
Longtime User
Hi Erel,
I have changed the code to add a map to the list object, which is then passed into the JSON object (by initialisation).
I know I'm probably still being a little dumb, but can you point me to the exact code to use for posting a JSON object to a c# RESTful web service.
Many thanks,
Laurence.
 
Upvote 0
Top