Reputation: 1866
I am requesting the /v1/products in node.js for getting list of cars available in a particular area but I am getting this :
{"fields":{"latitude":"Required","longitude":"Required"},"message":"Invalid request","code":"validation_failed"}
Code:
var https = require('https');
var data = {
'latitude': '37',
'longitude': '-122',
};
data = JSON.stringify(data);
var options = {
host: "api.uber.com",
path: "/v1/products",
method: "GET",
headers: {
"Content-Type": "application/json",
"Authorization": "Token myAppToken",
"Content-Length": Buffer.byteLength(data)
}
};
var req = https.request(options, function(res) {
var responseString = "";
res.on("data", function(data) {
responseString += data;
});
res.on("end", function() {
console.log(responseString);
});
});
req.write(data);
req.end();
Upvotes: 0
Views: 70
Reputation: 6377
Did you post a real latitude and longitude in the format they specified? Update code with actual lat and longitude.
I would start over though using the module that Uber recommends https://github.com/shernshiou/node-uber and follow the example closely.
Upvotes: 1