The following steps help you to understand how to set a custom JSON response for a successful journey execution instead of a standardized OK response.
What you'll need:
Skill level: Intermediate
Time required: 7 minutes
- Callable Journey
- Trigger: New call
- Action: Return raw response to API management
- An API collection with a configured endpoint and client profile
- A tool to execute the API endpoint
Configuring the trigger
- Rename the journey to Send a custom JSON response instead of an OK message.
- In the Event section, choose the Callable Journey app from the drop-down menu in the Apps field present right below the New Trigger button.
- Select the trigger event as New call from the drop-down menu in the Triggers field.
- Give a name to your journey in the Name field. E.g., Custom JSON response.
- Select application/json for the Request type and Response type fields:
Configuring the action
- In the Steps section, click on the Simple Action button and choose the Callable Journey app from the drop-down menu in the Apps list.
- In the Actions list, select the Return raw response to API management action.
- Select Success as Response type.
- Specify a custom JSON response that the journey should show upon execution instead of OK message. E.g.,
{"message": "The journey has executed successfully", "description": "You are receiving a custom JSON response instead of a pre-defined OK message that conveys no information" }
- Save and start the journey.
Creating an API endpoint
Now, let us create an endpoint for this journey. Navigate to Tools > API Management and select the collection in which you want to create an API endpoint for the above Callable Journey. Click the + Create a new Endpoint button. A form-like window will open with the following input fields:
- Name: The name of your API endpoint. E.g., Custom JSON response API.
- Callable journey: Select the above Callable Journey from the drop-down.
- Method: The method for this API call is as per the functioning of the callable journey. E.g., POST. The additional information about this API collection. Ensure you select the same method while executing the API else you’ll face an error.
- Path: The path of this API collection. E.g., card_details. This is the actual API path and gets path will append to the API collection path:
- Click Submit:
Now create a client profile to get an API key for the above-created API endpoint. Click here to know in detail. The client profile must look like the below:
Executing the journey
Open an API checker tool of your choice. Copy the API key and set the authorization header. Then copy the API endpoint, set the method to POST and execute it. You'll get the custom JSON response instead of OK:
Comments
0 comments
Please sign in to leave a comment.