hub.eb?material_id=307&track_id=408

REST Web Service Resources


A REST Web Service Resource connects to a single RESTful web service. You can use the Resource to declare the target endpoints that you wish to call along with custom headers and query parameters.

You can create a REST Web Service by right-clicking in the Entities Tree and selecting New > REST Web Service Resource. When creating one you need to specify:

  • The Base URI, the root address of the target REST Web Service.
  • At least one target endpoint, <default>.

Any number of target endpoints can be added to a REST Web Service Resource and each can define the following:

  • Endpoint URI the specific URL to the endpoint, relative to the Resource's Base URI.
  • HTTP Method the types of call being made to the endpoint, for example, GET, POST, PUT and DELETE.
  • Request Query Parameters included in the request's body as JSON objects.
  • Request Headers included as data items in the HTTP request.
  • Response Headers expected headers in the target endpoint's response.

Like all Resources, Resource Fields can be configured, mapped to a Form's Fields and && substituted in the Request Query Parameters and Request Headers.

Each Endpoint can be tested by clicking on its Test Rest Call button.

A Rest Web Service Resource can be added to a Form by dragging it into the Form's Resources View. The Resource's Resource Fields can be mapped to the Form's Fields by clicking the Show mappings for resource button.

Specific endpoints can be called using the Verj.io JavaScript API's resources interface, for example, resources.webResourceName.call(endpointName). If endpointName is omitted the default endpoint is called.

 

Steps


1

Create a REST Web Service Resource.

2

Enter http://verjtraining.verj.cloud/apps/api/coin as the Base URI.

3

Modify the <default> endpoint to use /flip as the Endpoint URI.

4

Test  the endpoint.

The endpoint will return the result of a fair coin flip as a JSON-encoded object. You will see a response in the form {“flip”: “Heads”}.

Current Module

Part of tracks

Related