Skip to main content

Hi all,

I am trying to run a workspace on FME Server (2019) through the Data Download service. This generally works fine in terms of authorization etc. I can successfully pass parameters (and directives) to it as a query string. However, one of the parameters is geometry, currently encoded as OGC Well-Known Text. The input for this parameter can become quite large, as the geometry will be passed to FME Server from a web map. When this happens, the URL exceeds tens of thousands of characters and this seems to break the request.

Because of this, I am trying to pass the request as POST, keeping all parameters in the body and thus the URL nice and short. However I can't get this to work - the parameters in the body are ignored and the workspace is run with the default parameters every time.

The FME Server Data Download logfile has this line every time:

POST request received. Redirecting to GET method.

 

Is it possible at all to use POST to start the Data Download service? If so, how do I pass parameters this way? If not, what is the suggested method to pass geometry to FME Server in such a way that I don't run into the size restriction?

I am passing a header as well, containing the token in Authorization, and 'application/json' in Accept and in Content-Type.

Hi @ngoorman! One of our colleagues suggested it should be possible to use POST with ContentType x-www-form-urlencoded. Have you tried if that works for you?


Hi @ngoorman! One of our colleagues suggested it should be possible to use POST with ContentType x-www-form-urlencoded. Have you tried if that works for you?

Hi @alyssaatsafe - I've just tried again and it does not make a difference. I constructed the headers as follows (it's a Python script):

'Content-Type' :'application/x-www-form-urlencoded',

'Accept' : 'application/x-www-form-urlencoded',

'Authorization' : 'fmetoken token={0}'.format(_fme_token)


Hi @alyssaatsafe - I've just tried again and it does not make a difference. I constructed the headers as follows (it's a Python script):

'Content-Type' :'application/x-www-form-urlencoded',

'Accept' : 'application/x-www-form-urlencoded',

'Authorization' : 'fmetoken token={0}'.format(_fme_token)

Oh and the CORS settings allow POST, and allow these three headers (they are the default settings). I've tried setting 'Supports Credentials' to True, but this did not make any difference either.


Hi @ngoorman,

If you x-www-form-urlencoded and send your parameter and parameter value in the body you can send tens of thousands of characters. I tested 40,000 characters of WKT in a parameter with the datadownload service using Postman, and it worked as expected. If you want to let us know what kind of issues you have having here or through a case we can help debug.

Thanks,

Richard

 

 

 


Hi @ngoorman,

If you x-www-form-urlencoded and send your parameter and parameter value in the body you can send tens of thousands of characters. I tested 40,000 characters of WKT in a parameter with the datadownload service using Postman, and it worked as expected. If you want to let us know what kind of issues you have having here or through a case we can help debug.

Thanks,

Richard

 

 

 

Hi @richardatsafe,

Very useful, thank you. I've installed Postman and recreated the request there (URL, body and headers). When I send it, FME Server works perfectly and accepts the parameters in the body.

When I then copy the code that Postman has generated for Python 3, and save that to a .py file and run it with Python 3, it does not work - I get the same behaviour as before where the body is ignored. The same happens when I tweak the code to work in Python 2.7 and run that way.

I have no idea what's going on though I'm happy to have confirmed that FME Server accepts the right request without issue. Python seems to do something to it that FME Server doesn't like - but even when I cut down the payload to just 'opt_responseformat=json' it doesn't work (getting HTML response instead).


Hi @richardatsafe,

Very useful, thank you. I've installed Postman and recreated the request there (URL, body and headers). When I send it, FME Server works perfectly and accepts the parameters in the body. 

When I then copy the code that Postman has generated for Python 3, and save that to a .py file and run it with Python 3, it does not work - I get the same behaviour as before where the body is ignored. The same happens when I tweak the code to work in Python 2.7 and run that way. 

I have no idea what's going on though I'm happy to have confirmed that FME Server accepts the right request without issue. Python seems to do something to it that FME Server doesn't like - but even when I cut down the payload to just 'opt_responseformat=json' it doesn't work (getting HTML response instead).

I've now put the most basic request into Postman, against an FME sample server. Same behaviour: works fine in Postman, stops working in Python with the exported code:

 


import requests

 

url = "https://demos-safe-software.fmecloud.com/fmedatadownload/Samples/austinDownload.fmw"

 

payload = 'opt_responseformat=json'

headers = {

  'Content-Type': 'x-www-form-urlencoded',

  'Authorization': 'fmetoken token=568c604bc1f235bbe137c514e7c61a8436043070',

  'Accept': 'application/json'

}

 

response = requests.request("POST", url, headers=headers, data = payload)

 

print(response.text.encode('utf8'))


I've now put the most basic request into Postman, against an FME sample server. Same behaviour: works fine in Postman, stops working in Python with the exported code:

 


import requests

 

url = "https://demos-safe-software.fmecloud.com/fmedatadownload/Samples/austinDownload.fmw"

 

payload = 'opt_responseformat=json'

headers = {

  'Content-Type': 'x-www-form-urlencoded',

  'Authorization': 'fmetoken token=568c604bc1f235bbe137c514e7c61a8436043070',

  'Accept': 'application/json'

}

 

response = requests.request("POST", url, headers=headers, data = payload)

 

print(response.text.encode('utf8'))

Hi @ngoorman,

 

I had success with my python but similar to postman I had to turn off the verify ssl certificate.  (verify=False)

 

import requests

 

url = "https://MyFMEServer/fmedatadownload/repository/WKT2.fmw"

 

payload = 'WKT=POINT%20%28-123.09875267568009%2049.25721245106853%29%20

 

headers = {

  'Authorization': 'Basic YWStbW46YWRtaW4=',

  'Content-Type': 'application/x-www-form-urlencoded'

}

 

response = requests.request("POST", url, verify=False, headers=headers, data = payload)

 

print(response.text.encode('utf8'))

 


Hi @ngoorman,

 

I had success with my python but similar to postman I had to turn off the verify ssl certificate.  (verify=False)

 

import requests

 

url = "https://MyFMEServer/fmedatadownload/repository/WKT2.fmw"

 

payload = 'WKT=POINT%20%28-123.09875267568009%2049.25721245106853%29%20

 

headers = {

  'Authorization': 'Basic YWStbW46YWRtaW4=',

  'Content-Type': 'application/x-www-form-urlencoded'

}

 

response = requests.request("POST", url, verify=False, headers=headers, data = payload)

 

print(response.text.encode('utf8'))

 

Hi @richardatsafe,

I've got it working now - thank you for your help. What did it was using 

'Content-Type': 'application/x-www-form-urlencoded' 

rather than

'Content-Type': 'x-www-form-urlencoded' 

The latter works in Postman but not in Python. Changing that one thing solved it - thanks again.


Reply