I have a post that works in postman but not in nodejs using request

I used the code feature of postman to create the code for nodejs using request but no results are returned. Using postman I get a status code of 200 and data is returned. When using node I get a status of 200 but an empty data set is returned.

Code generated for node with cookies modified for security

var request = require("request");

var options = { method: 'POST',
  url: 'https://www.netflix.com/api/shakti/v73fa49e3/pathEvaluator',
  qs: 
   { drmSystem: 'widevine',
 isWatchlistEnabled: 'false',
 isVolatileBillboardsEnabled: 'true',
 falcor_server: '0.1.0',
 withSize: 'true',
 materialize: 'true' },
  headers: 
   { 'cache-control': 'no-cache',
 'X-Netflix.browserName': 'Chrome',
 'X-Netflix.osVersion': '10.0',
 'X-Netflix.playerThroughput': '58194',
 Referer: 'https://www.netflix.com/browse/my-list',
 Accept: '*/*',
 'Content-Type': 'application/x-www-form-urlencoded',
 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
 'X-Netflix.esnPrefix': 'NFCDCH-02-',
 'X-Netflix.uiVersion': 'v73fa49e3',
 'X-Netflix.browserVersion': '75',
 Connection: 'keep-alive',
 Cookie: '',
 'X-Netflix.osName': 'Windows',
 'X-Netflix.clientType': 'akira',
 'Accept-Language': 'en-US,en;q=0.9,es;q=0.8',
 'Accept-Encoding': 'gzip, deflate, br',
 DNT: '1',
 'X-Netflix.osFullName': 'Windows 10',
 Origin: 'https://www.netflix.com' },
  form: 
   { path: 
  [ '["mylist",["id","length","name","requestId","trackIds"]]',
    '["mylist",{"from":0,"to":400},["availability","availabilityEndDateNear","delivery","interactiveBookmark","maturity","numSeasonsLabel","queue","releaseYear","runtime","seasonCount","summary","title","userRating","userRatingRequestId"]]',
    '["mylist",{"from":0,"to":400},"current",["hasAudioDescription","summary"]]',
    '["mylist",{"from":0,"to":400},"boxarts","_233x131","webp"]' ],
 ' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

NOTE: I copied the generated curl code and it returned data as expected.
Thank you.

I figured it out. The api was expecting the form: value as the body. I removed form: and stringified the value and sent it as the body.

New Code:

var request = require('request');
var qs = require('querystring')
var dataString = qs.stringify({
    path:
        ['["mylist",["id","length","name","requestId","trackIds"]]',
            '["mylist",{"from":0,"to":400},["availability","availabilityEndDateNear","delivery","interactiveBookmark","maturity","numSeasonsLabel","queue","releaseYear","runtime","seasonCount","summary","title","userRating","userRatingRequestId"]]',
            '["mylist",{"from":0,"to":400},"current",["hasAudioDescription","summary"]]',
      })

var headers = {
    'Accept': '*/*',
    'Accept-Language': 'en-US,en;q=0.9,es;q=0.8',
    'Connection': 'keep-alive',
    'Content-Type': 'application/x-www-form-urlencoded',
    'DNT': '1',
    'Origin': 'https://www.netflix.com',
    'Referer': 'https://www.netflix.com/browse/my-list',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',
    'X-Netflix.browserName': 'Chrome',
    'X-Netflix.browserVersion': '75',
    'X-Netflix.clientType': 'akira',
    'X-Netflix.esnPrefix': 'NFCDCH-02-',
    'X-Netflix.osFullName': 'Windows 10',
    'X-Netflix.osName': 'Windows',
    'X-Netflix.osVersion': '10.0',
    'X-Netflix.playerThroughput': '58194',
    'X-Netflix.uiVersion': 'v73fa49e3',
    'cache-control': 'no-cache',
    'Cookie': '';

//var dataString = ';
var options = {
    json: true,
    url: 'https://www.netflix.com/api/shakti/v73fa49e3/pathEvaluator?drmSystem=widevine&isWatchlistEnabled=false&isVolatileBillboardsEnabled=true&falcor_server=0.1.0&withSize=true&materialize=true',
    method: 'POST',
    headers: headers,
    body: dataString
};

function callback(error, response, body) {
    if (!error && response.statusCode == 200) {
        console.log(body);
    }
}

request(options, callback);
1 Like