XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #1 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> Code: 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
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> Code: 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
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #2 The simplest way is to use InitializePost2 and convert the string to bytes: Code: request.InitializePost2("http://example.com", "yourdata".GetBytes("UTF8")) It takes care of the content length. Upvote 0
The simplest way is to use InitializePost2 and convert the string to bytes: Code: request.InitializePost2("http://example.com", "yourdata".GetBytes("UTF8")) It takes care of the content length.
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #3 oh, ok, but what do do with this: <InputURL>[input image URL]</InputURL> and If i have multiple ones? edit: and would it look smthlike this then: "<InputURL>myurl</InputURL>".GetBytes("UTF8") xverhelstx Last edited: May 1, 2011 Upvote 0
oh, ok, but what do do with this: <InputURL>[input image URL]</InputURL> and If i have multiple ones? edit: and would it look smthlike this then: "<InputURL>myurl</InputURL>".GetBytes("UTF8") xverhelstx
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #4 Build a large string with all the required data (StringBuilder is recommended for such task). Eventually convert the string to bytes. Upvote 0
Build a large string with all the required data (StringBuilder is recommended for such task). Eventually convert the string to bytes.
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #5 k, Would it look like this then: "<InputURL>myurl</InputURL>".GetBytes("UTF8") or like this: "myurl".GetBytes("UTF8") xverhelstx? Upvote 0
k, Would it look like this then: "<InputURL>myurl</InputURL>".GetBytes("UTF8") or like this: "myurl".GetBytes("UTF8") xverhelstx?
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #6 Not sure that I understand the problem. Code: Dim s as String s = "your string" s = s & "jklfjwe fjwfl kwjfe lkfje " s = s & "klfjwe flkwj eflkw jeflkw fe" request.InitializePost2(url, s.GetBytes("UTF8")) Upvote 0
Not sure that I understand the problem. Code: Dim s as String s = "your string" s = s & "jklfjwe fjwfl kwjfe lkfje " s = s & "klfjwe flkwj eflkw jeflkw fe" request.InitializePost2(url, s.GetBytes("UTF8"))
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #7 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
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
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #8 Code: Dim s As String s = "<Job> <InputURL>[input image URL]</InputURL> " _ & "<InputType>[input type (PDF/TIF/PNG/JPG/etc.)]</InputType></job>" Request.InitializePost2("http://example.com", s.GetBytes("UTF8")) Are you asking how to build the string? Upvote 0
Code: Dim s As String s = "<Job> <InputURL>[input image URL]</InputURL> " _ & "<InputType>[input type (PDF/TIF/PNG/JPG/etc.)]</InputType></job>" Request.InitializePost2("http://example.com", s.GetBytes("UTF8")) Are you asking how to build the string?
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #9 I was wondering if I had to add the tags also <joburl>url or just url. xverhelstX Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #10 The data sent should be sent exactly as the server expects it. In your case you should send a complete XML message. Which means that you need to include the tags and also the XML header: <?xml version="1.0" encoding="UTF-8"?> Upvote 0
The data sent should be sent exactly as the server expects it. In your case you should send a complete XML message. Which means that you need to include the tags and also the XML header: <?xml version="1.0" encoding="UTF-8"?>
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #11 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
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
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #12 These are good questions. Please feel free to ask more questions as needed. You are sending an XML message as the POST data. You should create a string with the complete message and then send it with InitializePost2. The XML header should be part of the string. Upvote 0
These are good questions. Please feel free to ask more questions as needed. You are sending an XML message as the POST data. You should create a string with the complete message and then send it with InitializePost2. The XML header should be part of the string.
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #13 oh, ok something like this then: Code: 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
oh, ok something like this then: Code: 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
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #14 Yes. Setting the content encoding is probably a good idea. Upvote 0
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #15 ok, great. I got a response with the following: <JobStatus xmlns:....> <jobURL>www.example.com/87465119871</jobURL> <JobStatus/> How am I now able to go that that specific jobURL? XverhelstX Upvote 0
ok, great. I got a response with the following: <JobStatus xmlns:....> <jobURL>www.example.com/87465119871</jobURL> <JobStatus/> How am I now able to go that that specific jobURL? XverhelstX
Erel B4X founder Staff member Licensed User Longtime User May 1, 2011 #18 See the XML parsing tutorial: http://www.b4x.com/forum/basic4andr...utorials/6866-xml-parsing-xmlsax-library.html Upvote 0
See the XML parsing tutorial: http://www.b4x.com/forum/basic4andr...utorials/6866-xml-parsing-xmlsax-library.html
XverhelstX Well-Known Member Licensed User Longtime User May 1, 2011 #19 pff I don't get it on how to work with this and what it does. How am I able to receive the url this way :s Could u please show an example on how to do this? to get the <jobURL> xverhelstx Last edited: May 1, 2011 Upvote 0
pff I don't get it on how to work with this and what it does. How am I able to receive the url this way :s Could u please show an example on how to do this? to get the <jobURL> xverhelstx
XverhelstX Well-Known Member Licensed User Longtime User May 2, 2011 #20 how should i include the link now as an inputstream? Dim in As InputStream in = httpresponse xml parser.Parse(in, "Parser") in.Close xverhelstx Upvote 0
how should i include the link now as an inputstream? Dim in As InputStream in = httpresponse xml parser.Parse(in, "Parser") in.Close xverhelstx