Question

JSON fragmenter works fine in FME Workbench but throws an "Unexpected character: 't'. One of the following characters was expected: '"', '}' " while running the workspace through datastreaming service from another web app.

  • 14 March 2022
  • 7 replies
  • 19 views

Badge

Hi, I am trying to run the attached fme workspace in fme server as datastreaming service. The workspace works fine in FME Workbench and while running in FME server web interface as datastreaming service. However, I am trying to access this service from my web app. Below is how I am forming the request :

 

var httpRequest = new XMLHttpRequest();

httpRequest.open("POST", url, true);

httpRequest.setRequestHeader("Authorization","fmetoken token=*********")

httpRequest.setRequestHeader("Access-Control-Allow-Origin", "http://localhost:8080");

httpRequest.setRequestHeader("Accept","application/json;charset=UTF-8");

httpRequest.setRequestHeader("content-Type","application/x-www-form-urlencoded");

httpRequest.onreadystatechange = function()

{

if (httpRequest.readyState == 4 && httpRequest.status == 200)

{

console.log(httpRequest.responseText);

}

}

// send a request so we get a reply

httpRequest.send("data="+JSON.stringify(dataToBesent.toGeoJSON()));

}

 

This throws an Error - Unexpected character: 't'. One of the following characters was expected: '"', '}' " in the log file.

 

Below is the object dataToBeSent

 

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[402,406.567505],[416,276.542479]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[458,398.565965],[466,220.531699]]}},{"type":"Feature","properties":{},"geometry":{"type":"LineString","coordinates":[[514,405.567313],[498,188.525539]]}}]}

 

Has anyone encountered such a problem previously?

 

Below is a Snap of the completed job details. The JSON is inserted properly but still throws an error 😞 .

 

Snap of my completed job details. The parameter gets inserted properly but I still get the error 

 


7 replies

Userlevel 4

It might be the BOM (byte order mark) that is creating issues for console.log() here. Try setting "Write UTF byte order mark" to NO in the TEXTLINE writer in your workspace.

Web services usually don't bother with the BOM, as the content encoding is specified by the headers, not the content itself.

Badge

I think the error arises from FME (attached screenshot). Because of this error, no feature is passed further and feature written is zero.

Userlevel 4

I think the error arises from FME (attached screenshot). Because of this error, no feature is passed further and feature written is zero.

Try inserting a Logger just before the JsonFragmenter and post the output here. Also please post the configuration of the JsonFragmenter.

Badge

Try inserting a Logger just before the JsonFragmenter and post the output here. Also please post the configuration of the JsonFragmenter.

Hi again,

Here is the log details after inserting logger. The output marked with red is the one that throws error. The json in this case does not have quotes. I don't know why this is happening. But in the details of the job request data (image in the question I posted), the json seems to have the quotes. I have also attached the details of the one that works fine - marked in green (running from FME web interface and not through HTTP request)

Screenshot (163) 

Below is the screenshot of my workspace with config details

Screenshot (168)

Userlevel 4

Try inserting a Logger just before the JsonFragmenter and post the output here. Also please post the configuration of the JsonFragmenter.

I'm not sure why the quotes are missing in the red rectangle, but that definitely explains the error from the JSONFragmenter, since it's not longer valid JSON.

Badge +6

Hi @charu​ ,

 

Did you ever figure out what was causing this error? Was it the quotes or something else. I have the same error when passing geometry (GEOM) User Parameters from an third party application. The quotes seem to be correct in my instance. The same error does not occur when the workspace is executed in Desktop or run as a Server App.

 

Thanks!

 

Hi @charu​ ,

 

Did you ever figure out what was causing this error? Was it the quotes or something else. I have the same error when passing geometry (GEOM) User Parameters from an third party application. The quotes seem to be correct in my instance. The same error does not occur when the workspace is executed in Desktop or run as a Server App.

 

Thanks!

 

@billybob​  @charu​ 

Did you ever find a solution? I am having the same issue. It works on desktop but then I get the error when I run it on FME Flow.

 

Thanks!

Reply