iOS Question How to send JSON parameters in the Body of a HTTP Request (GET or POST)

WhiteWizard

Member
Licensed User
I made my first app in B4X using iHttpUtils2 and calling my API REST in NODEJS, using this code:

....
j.Initialize("",Me)
j.Download(Server & "/api//api/log/ParameterName1:"& User &"/ParameterName2:" & Pass)
wait for (j) JobDone (j As HttpJob)
....

However now in my Next API Version I got all the parameters in the Body of the request (I mean, I got to write the parameters in JSON format in the Body tab of PostMan).
How do I set the Body for my GETs and POSTs request?
 

Attachments

  • Sin título.png
    Sin título.png
    190.6 KB · Views: 243

drgottjr

Expert
Licensed User
Longtime User
i can't remember having seen get involving json. you sure about that?

as for a post, you create a json object with the json library, tell the server you're posting json and you use j.poststring with your json as the 2nd parameter.

the json library creates and reads a json object. use it to create your json. json doc

then

B4X:
j.poststring( "https://blahbla.com", myjson_object_to_string )
j.GetRequest.SetContentType("application/json")       ' yes, it comes after j.poststring()

wait for whatever answer you're expecting as usual.
 
Upvote 0
Top