JSONError in newman but not postman

Running requests successfully in postman, but get errors in newman.

newman version 3.9.3
macOS High Sierra 10.13.4

test code:
try {
responseJSON = JSON.parse(responseBody);
catch (err) {

newman output excerpt:
POST https://api.xxx.com/payment/notify ⠆ ⠇ ┌
│ { type: ‘Error’, name: ‘JSONError’, message: ‘Unexpected token u in JSON at position 0’ }
│ null

response body in postman looks like this:

@testmonger From the result of your code snippet, I can see that the response returned is null. Could you confirm the conditions under which your API returns such a response? Also, could you share the results of console.log(pm.response.json()); across the app and Newman?

@kunagpal Finally found a solution, related to authorization and environment variables. The environment variables used for authorization were working fine in postman, but required extra care when trying to access from newman.

(1) While running newman, I found it more reliable to specify the collection and environment as local json files rather than URLs. Example:

Use this in the newman shell script:

Instead of this:

(2) I need oauth credentials for some of the requests. But for the AWS elastic search requests (which are also included in the same collection), I had to include an additional parameter in the newman call: --insecure

So, the complete newman call that is successfully running for me looks like this:

newman run $PMCOL --folder $PMFOL -e $PMENV --ssl-client-cert xxx.crt --ssl-client-key xxx.key --ssl-client-passphrase xxx --insecure