Closed emtiazzahid closed 1 year ago
"Unexpected token < in JSON at position 0" typically indicates that the response is in html format. The first that comes to mind is that the error page of the site might be returned. This could be the case for a bad request (bad domain, bad data) or a request that lacks permission to perform what the endpoint is supposed to do.
Thanks for your reply. I think its related with dev_properties data I have here are the sample format I using. note: I have changed the characters for safety.
{
"domain": "use-opreno.sitevision-cloud.se",
"siteName": "my site",
"addonName": "mysiteaddon",
"username": "test@test.no",
"password": "eAl-Gfpse1GTFL"
}
and after I changed the username "test"
for test purpose the error is changed to
Upload failed, status code: SyntaxError: Unexpected end of JSON input
npm run create-addon mysiteaddon also gives same error
Addon creation failed:, SyntaxError: Unexpected end of JSON input
thanks @magloven . I had two problems and found that the issue was in siteName and permission issues. if we can catch the response error so we may get the more meaningful responses we get example here i added a catch in the fetch method
const response = await fetch(url, {
method: 'post',
body: JSON.stringify({ name: props.addonName, category: 'Other' }),
headers: {
Authorization: `Basic ${Buffer.from(
props.username + ':' + props.password
).toString('base64')}`,
},
}).catch(error => {
console.error(`${chalk.red('Error:')}, ${error}`);
});
that gave me that error response
{
"success": false,
"type": "invalidParameter",
"description": "An invalid parameter (query or request body) was specified",
"message": "BAD_REQUEST: Unable to process /rest-api/1/0/mySiteName/Addon%20Repository/custommodule, could not resolve context node"
}
so I found that the issue was in my site name
After running dev its showing that error. here are the log
node -v : v18.12.1 npm -v: 9.8.0
can anyone help please