I'm trying to fetch serveymonkey response in NodeJS. this is the response I'm getting:
{
error:
{ docs: 'https://developer.surveymonkey.com/api/v3/#error-codes',
message: 'The authorization token provided was invalid.',
id: '1011',
name: 'Authorization Error',
http_status_code: 401
}
}
And this is my code:
const fetch = require('node-fetch');
const accessToken = 'xxxxxxx';
let options = {
method : 'GET',
headers: {
Authorization: accessToken,
},
contentType: 'application/json'
};
fetch('https://api.surveymonkey.com/v3/surveys/6991347309/responses/6991347309',options)
.then(res => res.json())
.then(json => console.log(json));
The access token I checked a lot of times I copied it right from the app.
What am I doing wrong?
You're missing the prefix, bearer in the Authorization
header of your request:
Authorization: bearer YOUR_ACCESS_TOKEN
For more information, see the Authentication section of the API documentation.