I wanted to use the OkHTTPUtils library to POST to an API.
This is the code I use:
B4X:
Dim j As HttpJob
j.Initialize("", Me)
Dim json As JSONGenerator
json.Initialize(CreateMap("Username":"admin", "Password":"admin"))
j.PostString("http://localhost:10601/session", json.ToString)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
This works, but when I check the transmitted packets via Wireshark I notice that the data is not send "raw" but rather via x-www-form-urlencoded.
How can I POST a string to a URL "raw", or how to set the content-type of a POST request?
Description: The following code allows you to set the request headers before the request is sent. This is useful for example with sites that block requests without a User-Agent header. This code depends on HttpUtils2 and Http libraries: Dim j As HttpJob j.Initialize("job name", Me)...