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
first argument must be a string of Buffer #1904
Comments
What data type is |
It's this: |
So, basically the body should be either |
Well, in worked until now, so it means there was no problem per se with sending this new built-in type(whatever that is and whatever the it's relationship to Buffer is), I found some hotfixes I could employ, I just find it somewhat unnecessary: |
The error is thrown from core, not from this module. That's most probably related to platform upgrade - in case you upgraded your NodeJS version. Are you using request in the browser? What if condition? What was working until now? |
No, this error occurs, when I'm running it on node. It didn't happen until I upgraded npm (yesterday). |
That's weird idd. I found two possible suspects in the past PRs, but I need your exact code to reproduce the bug - a small self contained code example that I can run. |
How about this code? var request = require('request');
request.post({
url: 'https://clients4.google.com/chrome-sync/command',
qs: {
'client': 'Google+Chrome',
'client_id': '12345'
},
headers: {
'Content-Type': 'application/octet-stream',
'Authorization': 'Bearer 123'
},
encoding: null, // if you expect binary data
responseType: 'buffer',
body: new Uint8Array(3)
}, function(e,r,b){console.log(e,r,b)}); |
Fixed here #1905 |
Super, thanks! :) |
Hey guys, i have version 2.70.0 installed, but I am still struggling with this same error:
This is my code that I currently use: var options = {
url: url,
path: req.path,
qs: req.query,
method: req.method,
headers: headers,
responseType: 'buffer',
timeout: TIMEOUT
};
options.json = true;
options.body = {
"firstName": "Test1",
"lastName": "Test2",
"email": "test@gmail.com",
"mobilePhone": "+38631288288"
};
request(options, function (error, response, body) {
callback(error, response, body, options);
}); I hope my code and question are clear enough. |
Got this error too. @novellizator Can you reopen this please? |
@banomaster @Ohar |
@simov Oh thank you. res.write(data);
res.end(); it returns JSON, but I get this issue (#1904) on remote server. ExampleHandlerfunction foo (req, res) {
request.post(
'https://example.com/api',
{form: data},
function (error, response, body) {
res.json(body);
}
);
} Actual resonse
Desired response{
"response": {
"data": {}
},
"status": 0
} |
Set the |
Wow, bravo request team, way to break the interface without upgrading major versions :/ |
@mboudreau can you open up another issue and explain exactly what isn't working for you? |
Essentially, I have been using request since 2.64.x, and I've always just The reason I'm annoyed is because of the semantic versioning standard says I don't think it deserves it's own ticket, but just a warning of the On Fri, Apr 29, 2016, 5:28 PM simo notifications@github.com wrote:
|
I'm still not sure what is the expected behavior in your case? Are you expecting to pass an object to the Either way, you should provide a code example to reproduce the bug. From the docs:
You can test this: request({
method: 'POST',
url: 'http://requestb.in/tr4jaxtr',
body: {a: 1},
json: true,
callback: (err, res, body) => {
if (err) {
console.log(err)
}
console.log(body)
}
}) See the results here. As you can see the body is a stringified JSON object. |
Hey everyone, I have been fiddling with this error for a while, and here is what I found out. When the post request params is of type: To overcome this, I just did Also, if we set |
Basically do not use |
Sometimes the best answers are the very bottom of a thread. Thanks @itsyogesh @cozzbie |
@novellizator guys this was a closed issue, but I'm puzzled since I'm doing that for a binary image and get the same error:
|
Hey, just came across with a solution to this. I was sending a json |
I was using a |
i am also facing same error
|
Hi, I was running some code and got this error message:
Funny thing is, that if I replace the current version of request module with an older one(### v2.60.0 (2015/07/21), according to changelog), everything works just fine.
The code that causes this error is this:
The text was updated successfully, but these errors were encountered: