Skill level: Intermediate
Time required: 7 minutes
This article explains how to configure a custom JSON response for a successful journey execution instead of the default OK response.
Prerequisties
- A callable journey with:
- Trigger: New call
- Action: Return raw response to API management
- An API collection with a configured endpoint and client profile
- A testing tool like Postman to execute the API endpoint
Step-by-step guide
1. Configuring the trigger
- In the Event section, select the Callable Journey app from the Apps drop-down and choose New call as the trigger event,
- Give a name to your journey in the Name field. For example, Custom JSON response.
- Set application/json as the value for both the Request type and Response type fields.
2. Configuring the action
- In the Steps section, click Simple Action and select the Callable Journey app.
- Choose Return raw response to API management from the Action drop-down.
- Select Success as Response type.
- Enter a custom JSON response to replace the default OK message. For example, "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.
3. Creating an API endpoint
- Go to Tools -> API Management.
- Select the API collection where you want to create an endpoint.
- Click the + Create a new endpoint button.
- Fill out the input fields:
- Name: Name of the API endpoint (For example, Custom JSON response API).
- Callable journey: Select the callable journey created earlier.
- Method: Choose the HTTP method (For example, POST). Ensure you select the same method while testing the API else you will face an error.
- Path: Specify the API path (For example, card_details). This will be appended to the API collection path.
5. Click Submit.
4. Creating a client profile
Create a client profile to generate an API key for the new API endpoint. Refer to this guide for detailed steps. The client profile should resemble this:
5. Testing the API endpoint
- Open an API testing tool, such as Postman.
- Copy the API key and enter it in the Headers tab.
- Then copy the API endpoint, set the method to POST and execute it.
You will get the custom JSON response instead of OK.
Comments
0 comments
Please sign in to leave a comment.