span8
span4
span8
span4
This article has been depreciated, for current information on working with FME and REST, see the FME Server REST API Training course.
In the previous sections we have talked about REST and RPC and built a RPC web service. Now we will begin to create REST web services, by addressing a broader portion of the HTTP standard.
Let’s refer back to the our original definition of the functionality the web service should provide:
Now we will define the REST API based on these requirements.
Required Functionality | HTTP Method | URL Suffix |
Retrieve all of the parks in GeoJSON format. | HTTP GET | /parks |
Retrieve a subset of the parks based on filter criteria. | HTTP GET with query string | /parks |
Add a completely new park. | HTTP POST | /parks |
Update a park. | HTTP PUT | /parks/<parkname> |
Delete a park. | HTTP DELETE | /parks/<parkname> |
With REST, the HTTP Request-Method determines the action and the URL determines the resource to act on. So in a workspace we need to filter to an action using the Request-Method and extract the identifier out of the URL.
When a workspace is run on FME Server, the following parameters are provided with values:
As you might suspect, they provide the HTTP Request-Method and URL that were used in the web service call.
When you are authoring your workspace on FME Desktop, the parameters don’t have any values. So, for authoring purposes you should create two private parameters with the above names and set the values for testing.
Pasting a URL into a web browser has the effect of sending an HTTP GET request with a query string to the web service. REST Web Services require also DELETE, PUT, POST methods, configuration of the Request-Body, and more. Most programming languages have these capabilities, but writing a problem is overkill if we just want to test the web service.
Luckily there are quite a few clients for testing REST Web Services. Some browser based examples include REST Console, Postman, Advanced REST Client and HTTP Client. A popular command line tool cURL is a bit harder to use, but quite powerful. If you are using a Mac then HTTP Client works fine too. You will need to have one available for the remainder of the tutorial.
Creating REST Web Services.zip
Creating REST Web Services: 9. Conclusion (2015)
Tutorial: Creating REST Web Services (2015)
Creating REST Web Services: 1. An Overview of REST and RPC (2015)
Creating REST Web Services: 2. Defining the Web Service (2015)
Creating REST Web Services: 3. Authorization and CORS (2015)
Creating REST Web Services: 4. First an RPC Web Service (2015)
Creating REST Web Services: 6. Supporting HTTP POST (2015)
Creating REST Web Services: 7. Supporting HTTP PUT (2015)
Creating REST Web Services: 8. Supporting HTTP DELETE (2015)
© 2019 Safe Software Inc | Legal