Skip to main content

Hello FME community,

I’m developing a FME service that needs to process a JSON object, uses this JSON as upload body in a HTTPCaller that returns a ZIP file and emails the user a download link to the returned ZIP file.

What is working is a POST to datadownload service with a JSON upload body and the email as request parameter:

https://<fmeserver>/fmedatadownload/Samples/WritingZip.fmw?SourceDataset=&DestDataset=DownloadZip&opt_showresult=false&opt_servicemode=async&opt_requesteremail=test@test.com

With a subscription at the DATADOWNLOAD_ASYNC_JOB_SUCCESS topic I retrieve the desired mail with the download location using this template:

https://<fmeserver>/fmedatadownload/results/{@getFileName(OutputLocation)}

However, a developer asked me whether it is possible to integrate the request email in the POST body. Therefore I looked at the FME REST API and tried to POST it to:

https://<fmeserver>/fmerest/v3/transformations/submit/Samples/WritingZip.fmw, with upload body:

With the Email Template Keywords I couldn’t retrieve the download location anymore. Do you have any idea how I can retrieve the download location through the FME REST API or have another solution?

I have looked at posts of other dealing with a similar issue, however without a satisfying answer.

 

 

Kind regards,

GeoJan

It's slightly confusing, but the REST service and the fmedatadownload service are actually quite different "under the hood". As far as I know you cannot simply replace the fmedatadownload with any of the REST services.

If you want to use the REST service you could e.g. save the workspace result to $(FME_SHAREDRESOURCE_DATA)\\$(FME_JOB_ID).zip and then use the appropriate REST service to download it from there.

See for example https://knowledge.safe.com/questions/84972/how-download-file-in-resources-path-using-rest-api.html


It's slightly confusing, but the REST service and the fmedatadownload service are actually quite different "under the hood". As far as I know you cannot simply replace the fmedatadownload with any of the REST services.

If you want to use the REST service you could e.g. save the workspace result to $(FME_SHAREDRESOURCE_DATA)\\$(FME_JOB_ID).zip and then use the appropriate REST service to download it from there.

See for example https://knowledge.safe.com/questions/84972/how-download-file-in-resources-path-using-rest-api.html

@david_r, thanks for your response! So, I thought about this option as well, but do think it is quite cumbersome compared to the FME Data Download service. What do you see as the advantages of the REST service over the fmedatadownload service?


@david_r, thanks for your response! So, I thought about this option as well, but do think it is quite cumbersome compared to the FME Data Download service. What do you see as the advantages of the REST service over the fmedatadownload service?

There are mainly two things I dislike about the fmedatadownload service:

  • Basic auth only, I prefer using short lived tokens
  • Parameters in URL, I prefer having the parameters in the POST body

Both of these issues are related to security.

What I dislike about the REST API is that there's no real equivalent service, so you kinda have to reinvent the wheel. On the other hand, you can tailor it exactly to your needs.

Hopefully someone can correct me if I'm not quite up to date on the current version of the fmedatadownload service...


There are mainly two things I dislike about the fmedatadownload service:

  • Basic auth only, I prefer using short lived tokens
  • Parameters in URL, I prefer having the parameters in the POST body

Both of these issues are related to security.

What I dislike about the REST API is that there's no real equivalent service, so you kinda have to reinvent the wheel. On the other hand, you can tailor it exactly to your needs.

Hopefully someone can correct me if I'm not quite up to date on the current version of the fmedatadownload service...

@david_r, thanks again. So I think the developers I am working with, prefer to use the REST API as well because of the reasons you indicate. The engineers I am working with prefer to use the direct URL services. It would be helpful if the two are (more) interchangeable.

But do you know a way how to incorporate a NM directive like "email_to" together with a JSON object you want to POST for some transformation?


@david_r, thanks again. So I think the developers I am working with, prefer to use the REST API as well because of the reasons you indicate. The engineers I am working with prefer to use the direct URL services. It would be helpful if the two are (more) interchangeable.

But do you know a way how to incorporate a NM directive like "email_to" together with a JSON object you want to POST for some transformation?

Unfortunately there is no "email to" functionality available when using the REST API, you'll have to do everything manually.

The simplest is probably to just pass the email through a published parameter. In your workspace you can then use a FeatureWriter to output your dataset and then connect an Emailer to generate and send the email with the download URL to the client. That works well for me.


Reply