Creating REST Consumer

This section explains the process of creating web service consumer activity for RESTful Web Service.

Steps to create REST Consumer activity

  1. Click Configure > WEB SERVICES > REST Consumer.

  2. Click Create REST Consumer

  3. On the Create New REST Consumer window, provide a name for REST Consumer. 



  4. Enter the Endpoint URL of the REST web service in the Specify destination URL box. For example: http://example.com/post/ or http://example.com/script.php?method=post_data&cust=123.

  5.  Select the HTTP method from the drop-down list of Select HTTP method. You can select any of the following methods depending on what the application API supports:

    • Get
    • Put
    • Post
    • Patch
    • Delete

    GET is used to fetch data. POST is generally used to create or store new data, while PUT is used to update existing data. Patch is used to make minor changes or updates to the resource at the target location.

    Some considerations when creating the Source REST APIs include:

    • Depending on the API, POST and PUT at source may be used not only to send data but also to receive the data (response after executing a POST or PUT request).
    • Request Body field appears when POST and PUT methods are used at the source side. This is where you enter your actual data in the specified format (Content-Type).
    • Content-Type field is not visible with GET method.

    Some considerations when creating the Target REST APIs include:

    • Do you explicitly name your URL objects you create, or do you let the server decide the name? If you name them, then use PUT. If you let the server decide, then use POST.
    • PUT is idempotent, so if you PUT an object twice, it has no effect. This is a nice property that makes one use PUT when possible.
    • You can update or create a resource with PUT with the same object URL.
    • With POST you can have 2 requests coming in at the same time making modifications to an URL, and they may update different parts of the object.
  6. Click Add and enter the header parameters if needed by the target application.

    REST APIs use the HTTP standard. Therefore, any REST call headers are in fact HTTP headers. They define the operating parameters of the transaction, the so-called metadata. It is considered the bad practice to transmit actual data as a header field. Ideally, since each endpoint represents a state transfer, custom headers should only be used for things that do not involve the name of the resource (should be passed in the URL), the state of the resource (should be passed in the body), or parameters directly affecting the resource (should be passed as URL parameters). That leaves only true metadata about the request in custom headers.

  7. Select Post Data as Attachment if you want the data to be transferred as an attachment. Else, the data is included in-line in the URL request.

  8. Select a security policy from the Security Policy drop-down list.

    When you use either Put  or Post method, then following two additional options are displayed.

    • Post Query String
    • Enable Multipart

    Post query string is used to pass the query paramters in RESTful Request.  To send the query  parameters with Put or Post method, enable the Post Query String option and define the parameters in the Parameter table. 

    Enable Multipart is used to the post the file to the RESTful Webservice.  To send a file follow the below steps:

    • Enable the Enable Multipart option.
    • In the Part Name field enter the name of the form-data field.
    • Enter the name of the file in the File Name  field. This name will be used for the file, which will be posted to the Web Service. You have to pass the file, which you want to send through this consumer, as a source stream. You use file source activity to achieve it.
    • Modify the media type in the presentation table as explained below
    • Media type for Request should be multipart/form-data

    Media type for Response varies for different web service.  It can be application/json or application/xml.

    Change Content Type of Multipart and Disposition Order

    To change the Content-type of multipart and disposition order, you need to set the following variables in the process flow:

    For Content Type: Service.{EntityName}.attachmentMediaType

    For Disposition TypeService.{EntityName}.ReOrderContentDisposition = true

    here the EntityName is the web services consumer activity name, for example: Service.WeatherReport.attachmentMediaType=application/xml

  9. Select the project from the Select Project drop-down list.
  10. Click Save.