Posting JSON using url connection

I found a sample about url connection on language reference.

Var json As New JSONItem
json.Value("ID") = 123456

mySocket.SetRequestContent(json.ToString, "application/json")
mySocket.Send("POST", "")

I have a question, The url that I want to use for post the json data is using token key and user id.
where i have to put it here. is there any other method to define it. I have tried to add it on the url, but seems not working.

any helps


You must read your API docs, but usually some infos follows in the header as:

Var uc As New URLConnection

Var json As New JSONItem

json.Value("ID") = 123456

uc.RequestHeader("token") = "ajshdfjahsdhfkahsdjkfha" // follow your API docs
uc.RequestHeader("another_header_data") = "ajshdfjahsdhfkahsdjkfha" // more examples

uc.SetRequestContent(json.ToString, "application/json")

Var content As String = uc.SendSync("POST", "", 10)

Thanks its works.

but one more questions, how to grab the status. to make sure the data is posted or not.
in Linux shell via curl its shown, its mention if status=200 means success.
but I don’t know how to show the success message here.


thanks so much.


1 Like