Question

FME rest api request

  • 25 March 2019
  • 2 replies
  • 6 views

Is there an example of a node.js service call sending a file to FME rest api? In Postman you can select binary and that works. How do you do that in code though? What does the body look like? could you use formdata? What is FME expecting? I have reviewed https://www.safe.com/training/recorded/fme-server-2018-rest-api/ but I don't see how do this with code.

 

 


2 replies

Badge +9

Hello @lucaskaim,

 

I know we just discussed this on Live Chat. However, I felt like I should answer your question here as well because there may be other customers with similar questions. Also, if you have any additional questions I can answer them here.

 

 

We have a Javascript library called FMEServer.js. It integrates with the power of FME Server and its REST Services. This library allows you to easily connect your web applications with the advanced functionality of FME Server. Functions such as accessing a service, uploading data, scheduling, and notifications are all available through the library.

 

 

The full library can be found here: https://playground.fmeserver.com/javascript/javascript-library/get-the-library/

 

 

An example of how to upload a file using JavaScript: https://playground.fmeserver.com/javascript/server-uploads/upload-file-in-session/

Please note, that the code on the page is editable so you may edit it to your server to test it out.

 

 

Additionally, in Chapter 9 of the REST API Course, there is a section on building web applications.

https://s3.amazonaws.com/gitbook/Server-REST-API-2018/FMESERVER_RESTAPI9CustomApplications/9.0.ChapterIntroduction.html

 

 

I hope this helps you! Let me know if you have any questions.

 

Kind regards,

Sienna

Badge +2

Hi @lucaskaim

 

 

A while ago I wrote this article, which shows communication between FME Server and Node.JS: https://knowledge.safe.com/articles/44337/http-post-requests-to-fme-server-from-nodejs.html

 

 

You won't need any of the postgis stuff for what you've asked about, but I think working with request will allow you to use the FME Server REST API. To see how to upload form data or change the type like you did in postman, I'd recommend looking through the node module documentation or searching for an installing one that'll do what you're after. This might be useful if you do decide to use the request module: https://stackabuse.com/the-node-js-request-module/

 

Reply