"Execution of JavaScript-ResultSet failed with error: Javascript runtime error: \"SyntaxError: Unexpected token:

Not applicable

Somehow i keep gettting this error code. The link works fine without Apigee, I have had a look at it with several people but it's still unclear why the proxy doesn't work. Anyone experience with this problem?

And the link gives us the error:

{

  • "fault": {
    • "faultstring": "Execution of JavaScript-ResultSet failed with error: Javascript runtime error: \"SyntaxError: Unexpected token: <. (JavaScript-ResultSet.js:5)\"",
    • "detail": {
    • "errorcode": "steps.javascript.ScriptExecutionFailed"

}

  • }

}

3786-error.png

Thanks in advance.

0 17 1,905
17 REPLIES 17

Hi @sando,

Looks like the server is expecting data in json format, but the proxy is sending body payload as xml. This error mostly comes due to JSON.parse() function in javascript.

Could you please share the policy/proxy bundle? this will give us more details about the root cause of the error.

Cheers!

Hi Mohammed,

Thanks for your fast reply.

Do you mean like this:

3787-error1.png

and this is the full policy script:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ExtractVariables async="false" continueOnError="false" enabled="true" name="Extract-Variables-1">
<DisplayName>Extract Variables-1</DisplayName>
<Properties/>
<URIPath name="name"/>
<Header name="origin"/>
<Header name="OriginDepartureDate"/>
<Header name="destinationdeparturedate"/>
<Header name="DestinationArrivalDate"/>
<Header name="adults"/>
<Header name="price"/>
<Header name="limit"/>
<Header name="destination"/>
<FormParam name="name"/>
<Variable name="name"/>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<JSONPayload>
<Variable name="name">
<JSONPath>{example}</JSONPath>
</Variable>
</JSONPayload>
<Source clearPayload="false">request</Source>
<VariablePrefix>apigee</VariablePrefix>
<XMLPayload stopPayloadProcessing="false">
<Namespaces/>
<Variable name="name" type="boolean">
<XPath>//test/example</XPath>
</Variable>
</XMLPayload>
</ExtractVariables>

Not applicable

Hello @Sando,

What are you doing in the javascript ? Specially at line number 5 ? And what data is fed to the Javadcript at line number 5 ? Can you please share the API Proxy code ?

By looking at the error, I feel its trying to parse the data at Line Number 5, but the data is not Json, instead it has a tag ">" (probably xml).

The best way to help you here would be to look at the API Proxy code.

Hi Meghdeep,

With API Proxy code do you mean; the link of the proxy?

That would be:

helmsando-test.apigee.net/budget1_flightoffers-1? as the base, with the follow up:

origin=ams&origindeparturedate=20161028&destinationdeparturedate=20161110&adults=1&lowestpriceperdestination=true&limit=10

Can you please download the proxy bundle zip and add here ? Also, please add the request message.

api-info.zip

hope this makes things more clear

Thanks for the details. But I need the API Proxy Bundle (which would have all the API Proxy, Policy, Resource components). The way to do so is like this:

1. on GUI, go to the API Proxy.

2. Click on the project option and select the option "Download Revision"

Attach the downloaded zip file here.

Thanks for the bundle. Why I cant find the javascript file "ResultSet.js" in the bundle ? I need to look at what you are doing at line number 5 of the javascript file "ResultSet.js", which is absent in the API Bundle you attached.

I don't have a clue. I downloaded the revision as a whole and didn't delete anything.

with line number 5 you mean of the 'extract-variables' proxy?

Because the code of that one i posted above, not sure if that is what you mean though.

As part of your proxy flow, there is a js file called "ResultSet.js" getting executed and the line number 5 of that js file is causing this issue. I suspect the issue is due to Json Parse in that javascript file (As stated earlier that JSON parse is happening on xml data)

Since you do not have an idea and I cant see that js file in the proxy bundle you shared, may be the backend of your proxy , which is "https://api.transavia.com/v1/flightoffers" contains this js file.

To be very sure if the backend is generating this error, please check the response you are getting from backend in your proxy trace.

I am not sure, if you can access the source code of the backend, but the best practice would be to do that action (which I feel is the parsing) in a try-catch block.

Are you sure that there is a js file in this proxy? I can't find it anywhere. I can't see it standing in the proxy flow of the trace either.

Otherwise, will it help if I sent you our tempary loggin info? If you don't mind having a look for yourself?

The backend system, "https://api.transavia.com/v1/flightoffers" , runs on Apigee Edge and is apparently returning the error you are seeing, on line 5 of ResultSet.js.

In other words, there's no error in the example proxy you provided. The error is in the backend.