IM Policy Xpress - Using "REST Base Query"

Document ID : KB000012728
Last Modified Date : 14/02/2018
Show Technical Document Details
Introduction:

This how-to is illustrated by using JSONPlaceholder which is a simple fake REST API for testing and prototyping. 

See https://github.com/typicode/jsonplaceholder#how-to

 

By instance creating a resource using curl can be done as following: 

curl -X POST -d "userId=1&title=foo&body=bar" http://jsonplaceholder.typicode.com/posts 

This will return: 

{ "userId": 1, "title": "foo", "body": "bar", "id": 101 } 

Question:

From one IM Policy Xpress, How to pass the data ("userId=1&title=foo&body=bar") to this REST API service?

Answer:

You need to set those data into the Request Body, here with a json format.

 

You can run the test from a Data Element with the following settings:

    Category:Data Sources

    Type: REST Base Query

    Function: Basic Auth Invoke

    Base URL: http://jsonplaceholder.typicode.com/posts

    Operation: POST

    User Name: dummy

    Password: dummy

    Request Body: {"userId":1,"title":"foo","body": "bar"}

 

This test will return the following:

Confirmation:   The test has run successfully with following string representational output: "{"id":101,"title":"foo","body":"bar","userId":1}".

This demonstrates that you have properly passed the parameters since they have been processed with success.