Raw POST-request mit json im Körper

In ein Lua-Programm, mit modeMCU, ich stehe vor einem problem mit meinem HTTP-POST-request.

Ich Teste meine Anfrage gegen httpbin.org/post.

Will ich senden, json-Daten, so ist meine bitte :

POST /post HTTP/1.1
Host: httpbin.org
Connection: close
Accept: */*
User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)
Content-Type: application/json

{...some JSON here}

Die Antwort ist :

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 07 Sep 2015 10:39:12 GMT
Content-Type: application/json
Content-Length: 332
Connection: close
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true

{
  "args": {}, 
  "data": "", 
  "files": {}, 
  "form": {}, 
  "headers": {
    "Accept": "*/*", 
    "Content-Type": "application/json", 
    "Host": "httpbin.org", 
    "User-Agent": "Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)"
  }, 
  "json": null, 
  "origin": "5.51.195.252", 
  "url": "http://httpbin.org/post"
}

Ich habe versucht 2 andere syntax für meinen Körper:

POST /post HTTP/1.1
Host: httpbin.org
Connection: close
Accept: */*
User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)
Content-Type: application/json

json:{...some JSON here}

und

POST /post HTTP/1.1
Host: httpbin.org
Connection: close
Accept: */*
User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)
Content-Type: application/json

"json":"{...some JSON here}"

Keiner funktioniert ...

Haben Sie eine Idee?

Hinweis: wenn ich mit einem curl -v -d @somejson.json -H "Content-Type: application/json" -i -v "http://httpbin.org/post" es funktioniert, aber ich Schaffe es nicht, die raw-Anfrage

Haben Sie versuchen, hinzufügen Content-Length - header in der POST-Anforderung ?
Und... ja, das ist die soltion (gefunden gestern von mir selbst nach stundenlangem Debuggen) danke!
Ihr willkommen ! Wenn Sie Ihr problem lösen, könnte es sein nett und hilfsbereit, Sie posten Sie Ihre Antwort.

InformationsquelleAutor bixente57 | 2015-09-07

Schreibe einen Kommentar