You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following code const campaigns = await customer.query( it fails with error:
Error: Parser cannot parse input: expected a value
at Parser._processBuffer (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/Parser.js:111:64)
at Parser._transformBuffer (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/utils/Utf8Stream.js:24:10)
at Parser._transform (/Users/me/Projects/project/backend/node_modules/.pnpm/stream-json@1.8.0/node_modules/stream-json/utils/Utf8Stream.js:19:10)
at Parser.Transform._write (node:internal/streams/transform:171:8)
at writeOrBuffer (node:internal/streams/writable:564:12)
at _write (node:internal/streams/writable:493:10)
at Parser.Writable.write (node:internal/streams/writable:502:10)
at IncomingMessage.ondata (node:internal/streams/readable:1007:22)
at IncomingMessage.emit (node:events:518:28)
at IncomingMessage.emit (node:domain:488:12) {stack: 'Error: Parser cannot parse input: expected a … at IncomingMessage.emit (node:domain:488:12)', message: 'Parser cannot parse input: expected a value'}
Full code example:
constcustomer=client.Customer({customer_id: 'customers/XXX',refresh_token: credentials.key,});try{constcampaigns=awaitcustomer.query(` SELECT campaign.id, campaign.name FROM campaign `);}catch(error){console.error(error);}
It appears to receive a 404 when issuing a request towards this URL:
The customer ID should be without the customer/ prefix. I was initially simply looping through the return of const customerIds = (await client.listAccessibleCustomers(credentials.key)).resource_names which automatically included the prefix. When the API returns a 404 the library cannot properly handle the error message, and that's when the Parser cannot parse input: expected a value error occours
The library should properly handle 404 errors from the API
simplenotezy
changed the title
Error: Parser cannot parse input: expected a value
API should handle 404 errors correctly
Aug 28, 2024
Thanks, @simplenotezy, for the solution you found. Yes, the error is not handled properly after console logging inside node_modules. I got to know something was 404 but didn't know the reason. After your suggestion, the below code worked for me.
With the following code
const campaigns = await customer.query(
it fails with error:Full code example:
It appears to receive a 404 when issuing a request towards this URL:
https://googleads.googleapis.com/v16/customers/customers/XXX/googleAds:searchStream
When removing the
customers/
prefix, the query works as intended.Possible solutions:
The text was updated successfully, but these errors were encountered: