Solved

FME server webhooks: passing geojson polygon-coordinates in URL

  • 7 December 2021
  • 1 reply
  • 9 views

Userlevel 3
Badge +18

Hi, taking my first steps in the FME REST API and webhooks, and struggling on passing coordinates.

 

I published a simple workspace to FME server using the Geometry Pïcker as only parameter, the drawn polygon is noted in GeoJson, like:

{"type":"Polygon","coordinates":[[[3.732869,51.016178],[3.733537,51.016688],[3.734896,51.015998],[3.734086,51.015473],[3.732869,51.016178]]]}

 I created a webhook from this workspace, the URL preview shows the special characters should be encoded, like:

https://FMEserver/workspace.fmw?DrawnPolygon=%7B%22type%22%3A%22Polygon%22%2C%22coordinates%22%3A%5B%5B%5B3.732869%2C51.016178%5D%2C%5B3.733537%2C51.016688%5D%2C%5B3.734896%2C51.015998%5D%2C%5B3.734086%2C51.015473%5D%2C%5B3.732869%2C51.016178%5D%5D%5D%7D&opt_showresult=false&opt_servicemode=sync  

but, when I GET-request through this URL, the workspace fails:

55	2021-12-7 17:05:35 | A JSON syntax error was found at line 1, column 2
56 2021-12-7 17:05:35 | Unexpected character: 't'. One of the following characters was expected: '"', '}'
57 2021-12-7 17:05:35 | The value of the import attribute '__GeometryReplacerTemp__' contained invalid JSON, and could not be parsed
58 2021-12-7 17:05:35 | The below feature caused the translation to be terminated

Looks like the polygon is not decoded correctly, as it is missing the "-characters?

62	2021-12-7 17:05:35 | Attribute(encoded: UTF-8) : `_DrawnPolygon' has value `{type:Polygon,coordinates:[[[3.732869,51.016178],[3.733537,51.016688],[3.734896,51.015998],[3.734086,51.015473],[3.732869,51.016178]]]}'
 
72 2021-12-7 17:05:35 | GeometryReplacer_<Rejected> (TeeFactory): GeometryReplacer_<Rejected>: Termination Message: 'GeometryReplacer output a <Rejected> feature. To continue translation when features are rejected, change 'Workspace Parameters' > Translation > 'Rejected Feature Handling' to 'Continue Translation''

Am I missing something? Should I encode/decode in a different way?

 

At the end, I hope to get input from a user through a custom webmap (ArcGIS Online and/or Leaflet), and use webhooks/RESTAPI to launch FME server workspaces, so there might be more convenient ways to do this, just trying to understand what goes wrong for now...

icon

Best answer by hollyatsafe 20 December 2021, 15:29

View original

1 reply

Badge +2

Update: This issue has been resolved for FME 2022.0. 

 

Hi @becchr​ , 

 

I'm sorry that you encountered this problem, I have been able to reproduce the issue you have described and I believe the problem is with how FME is storing the parameter value in the command line arguments when submitted via a Webhook. I have filed a bug to request this fix (internal reference: FMESERVER-17647) and will update this post when it is resolved. 

In the meantime, you can workaround this issue in one of two ways: 

 

1. In the Webhook URL replace the quote encoded reference (%22) with <quote> e.g. 

https://FMEserver/workspace.fmw?DrawnPolygon=%7B<quote>type<quote>%3A<quote>Polygon<quote>%2C<quote>coordinates<quote>%3A%5B%5B%5B3.732869%2C51.016178%5D%2C%5B3.733537%2C51.016688%5D%2C%5B3.734896%2C51.015998%5D%2C%5B3.734086%2C51.015473%5D%2C%5B3.732869%2C51.016178%5D%5D%5D%7D&opt_showresult=false&opt_servicemode=sync

2. In the Workspace, fetch the parameter into an attribute and use a series of StringReplacer transformers to add quotes around type, polygon and coordinates before feeding the attribute into the GeometryReplacer. 

Reply