node.jshttpspostmanlinkedin-apivoyager

valid json response with Postman but Invalid response with https module


I am calling this endpoint

https://www.linkedin.com/voyager/api/typeahead/hitsV2?keywords="sousse tunisia"&origin=OTHER&q=type&queryContext=List(geoVersion-%3E3,bingGeoSubTypeFilters-%3EMARKET_AREA%7CCOUNTRY_REGION%7CADMIN_DIVISION_1%7CCITY)&type=GEO

With Postman I get a valid json response. but when I call the same endpoint using https module in node.js code, I get an invalid json response with status 200. the invalid response is something like this �������Q�[@��=��M�x��Ik�CzEa:H

I am using the accept header like this: _headers['accept']= 'application/vnd.linkedin.normalized+json+2.1'


Solution

  • the other endpoint used a gzip encryption. but this endpoint doesn't. so I just set the accept-encoding to empty _headers["accept-encoding"] = "". It was confusing that even with the wrong encoding postman showed a correct response.