The CreatorCon Call for Content is officially open! Get started here.

com.glide.script.RhinoEcmaError: Unexpected token: <

BALAJI K R
Tera Expert

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: }

 

 

2 REPLIES 2

Maddysunil
Kilo Sage

@BALAJI K R 

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:

  1. 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.

  2. 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.

  3. 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.

  4. 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

Amit Pandey
Kilo Sage

Hi @BALAJI K R 

 

Can you share your script and requirement so that I can help you.

 

Regards,

Amit