sirjo66 Well-Known Member Licensed User Longtime User Sep 4, 2023 #1 Hi, in my app I have an HttpServer Code: Copy Private server As HttpServer in event HandleRequest I need to read the parameters, and I use this code Code: Copy Log("Mtd: " & Request.Method) Log("URI: " & Request.RequestURI) 'handle the request based on the URL Log("Cell: " & Request.GetParameter("cell")) Log("Text: " & Request.GetParameter("testo")) This work very well if I call it with GET method, but if I call it with POST method I don't read any parameter How can I read POST parameters ? I make POST call with "multipart/form-data" content type. If I call my server http with a normal browser (for example Firefox) and an HTML page, it works. If I call my server http with .NET program (with WebRequest object or WebBrowser object) it don't works. .NET code is correct, if I try to call others POST server, the answer is correct, it tell me what is the parameters and it is ok Thanks Sergio
Hi, in my app I have an HttpServer Code: Copy Private server As HttpServer in event HandleRequest I need to read the parameters, and I use this code Code: Copy Log("Mtd: " & Request.Method) Log("URI: " & Request.RequestURI) 'handle the request based on the URL Log("Cell: " & Request.GetParameter("cell")) Log("Text: " & Request.GetParameter("testo")) This work very well if I call it with GET method, but if I call it with POST method I don't read any parameter How can I read POST parameters ? I make POST call with "multipart/form-data" content type. If I call my server http with a normal browser (for example Firefox) and an HTML page, it works. If I call my server http with .NET program (with WebRequest object or WebBrowser object) it don't works. .NET code is correct, if I try to call others POST server, the answer is correct, it tell me what is the parameters and it is ok Thanks Sergio
Solution sirjo66 Sep 5, 2023 SOLVED I changed .NET code. Now I don't use WebRequest object (that it needs to build the request step by step) but I use HttpClient object, and it works
SOLVED I changed .NET code. Now I don't use WebRequest object (that it needs to build the request step by step) but I use HttpClient object, and it works
aeric Expert Licensed User Longtime User Sep 5, 2023 #2 You may check how I do it in my Web API template Upvote 0
DonManfred Expert Licensed User Longtime User Sep 5, 2023 #3 aeric said: how I do it in my Click to expand... httpserver is not jserver Upvote 0
Star-Dust Expert Licensed User Longtime User Sep 5, 2023 #4 https://www.b4x.com/android/forum/t...-and-parameters-httpserver.126535/post-919085 Upvote 0
aeric Expert Licensed User Longtime User Sep 5, 2023 #5 DonManfred said: httpserver is not jserver Click to expand... Oh sorry. I thought it is similar. I don't use httpserver. Upvote 0
DonManfred said: httpserver is not jserver Click to expand... Oh sorry. I thought it is similar. I don't use httpserver.
sirjo66 Well-Known Member Licensed User Longtime User Sep 5, 2023 #6 Star-Dust said: https://www.b4x.com/android/forum/t...-and-parameters-httpserver.126535/post-919085 Click to expand... This is the first thread that I have read, but it don't works It return an empty list Upvote 0
Star-Dust said: https://www.b4x.com/android/forum/t...-and-parameters-httpserver.126535/post-919085 Click to expand... This is the first thread that I have read, but it don't works It return an empty list
Star-Dust Expert Licensed User Longtime User Sep 5, 2023 #7 Previous to the post that I have indicated there is another one that reads the entire header, try it. Is it possible that the parameters it sends are not found in the header but in the body? Upvote 0
Previous to the post that I have indicated there is another one that reads the entire header, try it. Is it possible that the parameters it sends are not found in the header but in the body?
sirjo66 Well-Known Member Licensed User Longtime User Sep 5, 2023 #8 Star-Dust said: Previous to the post that I have indicated there is another one that reads the entire header, try it. Is it possible that the parameters it sends are not found in the header but in the body? Click to expand... I tried it but don't works. Yes, I think that the parameters are in the body, I build myself the call, using boundary, and Content-Disposition: form-data; name="paramName" "paramValue" and so on. This is because I need also to send a file. If I try this call with some site for to test the call (for example http://httpbin.org/post) it works, it show me the parameters call and it is correct. As I wrote, if I try to call it by Firefox or Chrome (with an HTML page), it works. Is there a simple method for to sniffer what browser send ? EDIT: I will try it with postman program Last edited: Sep 5, 2023 Upvote 0
Star-Dust said: Previous to the post that I have indicated there is another one that reads the entire header, try it. Is it possible that the parameters it sends are not found in the header but in the body? Click to expand... I tried it but don't works. Yes, I think that the parameters are in the body, I build myself the call, using boundary, and Content-Disposition: form-data; name="paramName" "paramValue" and so on. This is because I need also to send a file. If I try this call with some site for to test the call (for example http://httpbin.org/post) it works, it show me the parameters call and it is correct. As I wrote, if I try to call it by Firefox or Chrome (with an HTML page), it works. Is there a simple method for to sniffer what browser send ? EDIT: I will try it with postman program
Star-Dust Expert Licensed User Longtime User Sep 5, 2023 #9 if they are in the body then these parameters will always return empty Upvote 0
sirjo66 Well-Known Member Licensed User Longtime User Sep 5, 2023 #10 SOLVED I changed .NET code. Now I don't use WebRequest object (that it needs to build the request step by step) but I use HttpClient object, and it works Upvote 0 Solution
SOLVED I changed .NET code. Now I don't use WebRequest object (that it needs to build the request step by step) but I use HttpClient object, and it works