Solved

Can I upload a file a an FME Cloud service via http POST and use it as the reader source?


Badge

Hi all

I've had a read of related topics and still need some clarification. What I'd like to do is kick off a jobsubmitter service via http POST and use the file uploaded (csv or shape file) via the POST as the source data for the reader in the service. I'm testing using Postman and this is what I'm trying to post:

This article states that you can't use form-data in the body, only raw data. Does this mean the method I'm using won't work or has someone managed to get it to work? If this is possible, how do you set the FME Cloud location the file upload will be uploaded to?

If this method is not possible, I was thinking of using the upload service to upload the file then run the workspace when the upload arrives in the destination folder in FME Cloud (kick off process via notifications).

Any other suggestions would be most welcome.

Thanks

Rob

icon

Best answer by rkay 6 July 2017, 02:51

View original

3 replies

Userlevel 4

Have you looked at the relevant examples at the FME Server Playground?

http://playground.fmeserver.com/using-the-rest-api/resources/

Badge

If anyone is trying to do the same, here's how I got it working using the REST API file upload service (as suggested by @david_r) via Postman.

POST example:

https://mycloud.fmecloud.com/fmerest/v2/resources/connections/FME_SHAREDRESOURCE_DATA/filesys/GDA2020/UPLOADS?createDirectories=false&overwrite;=true&token;=sdf65we8r7s31we7sdf6g54wer

The token can be requested like this via the token service:

https://mycloud.fmecloud.com/fmetoken/service/generate?user=username&password;=password&expiration;=15&timeunit;=minute

In Postman

This method also allows you to upload multiple files. Once the files are uploaded, you know where they are located as you defined that location in the file upload POST so you can pass it to the processing workspace via published parameter or by other means.

At first I tried defining the Content-Type header as follows:

but was getting this error:

{ "message": "org.jvnet.mimepull.MIMEParsingException: Missing start boundary" }

I think Postman handles the boundary and the POST is already defined as form-data in the POST body (see above) so no need to set the Content-Type header. Once removed it worked fine.

Hope this helps

Badge +3

I think that if you can do it with Postman, it should also be possible to do it with the HTTPCaller using the same settings.

Reply