HTTP Post Message body

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello there,

I am currently working on my new project, and I need some help.

I need to send a HTTP Post request to this url for example: http://example.com/ and I need to give parameters in the message body.
How do i do this?
for example this:
<InputURL>[input image URL]</InputURL>
<InputType>[input type (PDF/TIF/PNG/JPG/etc.)]</InputType>

B4X:
        Dim request As HttpRequest
   request.InitializePost("http://example.com/",
   request.SetContentType("text/xml")
   request.Timeout=50000
   If HttpClient1.Execute(request, 1) = False Then Return
   ProgressDialogShow("Please wait...Searching")

Now, I don't know what I need to put in the inputstream and length, and how to handle the parameters..

Can you please help me? It would me really much appreciated.

Thanks
XverhelstX
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
I need to submit a job by sending an HTTP POST request to the following URL:
www.example.com

The request message body should contain XML of the following format (explained in detail below):

<Job>
<InputURL>[input image URL]</InputURL>
<InputType>[input type (PDF/TIF/PNG/JPG/etc.)]</InputType> <!-- Optional --
</job>

XverhelstX
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
How should i include the header:

request.SetHeader(<?xml version="1.0" encoding="UTF-8"?>

and does I need anything for this?
request.SetContentEncoding

Sorry for stupid questions, i'm not so conventient with HTTP
this would probably be my final question.

XverhelstX
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
oh, ok something like this then:


B4X:
Dim s As String
s = "<?xml version="1.0" encoding="UTF-8"?><Job> <InputURL>[input image URL]</InputURL> " _
 & "<InputType>[input type (PDF/TIF/PNG/JPG/etc.)]</InputType></job>"
Request.InitializePost2("http://example.com", s.GetBytes("UTF8"))

so i also don't need a request.setheader() and request.SetContentEncoding(
)

only request.SetContentType("text/xml")?

XverhelstX
 
Upvote 0
Top