-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Reading 'plain' argument from node.js request #2962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Are you sure the body of the node.js request is what you posted? Judging from the capitalization of the headers, it seems like you might be reconstructing it, and not copy/pasting? I've had better luck in Javascript sending a string-ified JSON blob. At least with jquery, even when setting Maybe try something like:
? |
Yes, i'm sure, those requests are copied from wireshark. I tried serialize object to JSON like in your example and they still are empty. But, capitalization of the headers souldn't be a problem, that was repaired #2131 |
I didn't mean to suggest that capitalization was actually a problem, only that it seemed like it might indicate the request wasn't copy-pasted. It seems like this is where the "plain" arg is getting set, and if I'm reading it right, it's only not set when the content type is What do |
i can't check it right now, but what I remember number of args was 0, ( |
NodeMCU code
Node.js code same as before. |
is |
I didn't saw that mistake, but |
I have the same problem. I cannot read the POST data via |
I think the issue is when the ESP8266 looks for Most of the node.js libraries will send the Using node/request as an example. If I set the let body = JSON.stringify({targetMode: mode})
request.post(this.url, {
body: body,
headers: {
'content-length': Buffer.byteLength(body)
}
}) If I set the let body = JSON.stringify({targetMode: mode})
request.post(this.url, {
body: body,
headers: {
'Content-Length': Buffer.byteLength(body)
}
}) You can replicate it in This does not work: curl -X POST -d '{"targetMode": "heat"}' -H "content-length: 21" http://esp8266.local This does work: curl -X POST -d '{"targetMode": "heat"}' -H "Content-Length: 21" http://esp8266.local I'm not very familiar with c++/arduino yet, but it seems like the code at least attempting to ignore case here: } else if (headerName.equalsIgnoreCase("Content-Length")){
contentLength = headerValue.toInt();
} Edit: seems this is fixed in the latest pre-release as per the code above. I was using the latest stable release, 2.3.0 which has this issue. |
Closing per last Edit in last comment. |
Basic Infos
Hardware
Hardware: NodeMCU
Core Version: Latest
Description
I'm trying to send JSON as POST data. Using Postman nodemcu read data perfectly. But when request from node.js 'server.arg("plain")' returns empty string.
Requests from wireshark below:
Debug Messages
POSTMAN reqest
NODE.JS simple request
Sample node.js code using unirest
The text was updated successfully, but these errors were encountered: