com.glide.script.RhinoEcmaError: Unexpected token: <
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 01:45 AM - edited 04-23-2024 01:45 AM
Hi,
I'm getting this below error, Please provide your inputs
com.glide.script.RhinoEcmaError: Unexpected token: <
sys_script.97641d871b18fd102ccb20a1604bcb4b.script : Line(19) column(0)
16: var responseBody = response.getBody();
17: gs.info('BK BR resp ' + responseBody);
18: //parsing response
==> 19: var resObj = JSON.parse(responseBody);
20:
21: if (resObj.statusCode == "01") {
22: gs.eventQueue('x_xyt_dps.po processer update failure', current);
23: }
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 02:26 AM
The error message "Unexpected token: <" typically indicates that the response you're trying to parse as JSON is not actually valid JSON, and it might be HTML or some other format.
Here are a few steps you can take to troubleshoot this issue:
Check the Response Content: Log or inspect the content of responseBody to see what exactly is being returned by the service you're calling. It's possible that the response contains an error message or some HTML content instead of JSON.
Verify the Endpoint: Make sure that the endpoint you're calling is correct and that it returns the expected JSON response. Sometimes, incorrect URLs or server-side errors can cause unexpected responses.
Handle Errors: Implement error handling in your script to gracefully handle cases where the response is not valid JSON. You can use try-catch blocks to catch JSON parsing errors and handle them appropriately.
Debugging: If possible, use debugging tools or log statements to trace the execution flow of your script and identify where the unexpected response is coming from.
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2024 03:15 AM