Go Down

Topic: HttpClient post request return only -1 not 200.  (Read 179 times) previous topic - next topic

kotran

Hello

I'm sending Image byte data to server.

String payload is like
value=255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,0,0,0,0,0,255,219,0,67,0,12,8,9,11,9,8,12,11,10,11,14,13,12,14,18,30,20,18,17,17,18,37,26,2


         
        HTTPClient httpClient;
         httpClient.begin(targetUrl);
         httpClient.addHeader("Content-Type","application/x-www-form-urlencoded");
         int httpCode = httpClient.POST(payload);
        Serial.println("httpcode");
         Serial.println(httpCode);
        httpClient.end();

but httpCode is always -1
and I checked server's logs. It didn't reach.

below is node js server that image should arrive.

      app.post('/pic',function(request,response){

       }

J-M-L

Don't post snippets...

What is in targetUrl? Is that a correct address? Can you reach it from your computer?what happens if you submit your POST?
How is the network configured on your arduino?
What does httpClient.begin(targetUrl); return?
Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums
Pas de messages privés SVP

PaulS

Quote
I'm sending Image byte data to server.
In the stupidest possible way, apparently.

Why on earth would you send binary data as text?
The art of getting good answers lies in asking good questions.

kotran

I thought firstly sending byte data seperated by comma then, on server, I could make string data to image byte .

targetUrl is http://camerauploading.herokuapp.com/pic and work find with postman test(sending sth with post)

Node js server is as below
and for postman post Test. it comes to pic come logs and request method is logged as POST .
but once I request post. I didn't reach here and httpCode result is -1 . not 200

 app.post('/pic',function(request,response){
   console.log("pic come");
  console.log(request.method);
   if (request.method === 'POST') {

   }
  }

PaulS

Quote
I thought firstly sending byte data seperated by comma then, on server, I could make string data to image byte .
Are the bytes separated by commas in the image file? NO.

There must be some part of "POST ALL OF YOUR CODE" that you find difficult to understand.
The art of getting good answers lies in asking good questions.

J-M-L

See #1 and provide feedback to all questions
Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums
Pas de messages privés SVP

Go Up