REST API Calls with Query Parameters in BizTalk: A Step-by-Step Guide
Introduction
In this blog, I will provide a comprehensive guide on how to call a REST API that requires query parameters. We'll walk through the necessary steps to set up the environment and make successful API calls.
Solution
High Level Steps
1. API Overview:
We will be using an open API for demonstration purposes. The API endpoint we'll be working with is:
https://randomuser.me/api/?results=1
2. Schema Creation:
- Create a schema named "SourceA" that matches the structure of the messages you'll be dropping in the receive location.
- To create a JSON response schema, follow these steps: capture the JSON response by running a test in Postman, and then utilize a JSON schema generator to create the desired JSON schema.
- In the SourceA schema, promote the field called "results." This field will serve as the variable for the query parameter.
4. Receive JSON Pipeline:
- Develop a receive JSON pipeline that can receive JSON messages and convert them into XML messages, preparing them for further processing.
- Deploy the schema project and the pipeline project
5. Receive Port and Location Setup:
- Create a receive port and, within it, establish a receive location.
- Set up a request-response send port using the WCF-WebHTTP adapter to call the REST API.
- Under the Messages tab set "Suppress Body" for Verbs to "GET"
- Configure the send port to subscribe to the receive port.
- Create a separate send port to subscribe to the response message and archive it for future reference.
7. Testing:
With the setup complete, drop a message with the "SourceA" schema in the receive location.
Observe that the REST API is successfully called, and the response message is received and archived for further analysis.
8. Code
The project is uploaded at the following location
https://drive.google.com/file/d/1uvlDP36xVgxaFi6VKzDnxqjls_pyjuop/view?usp=sharing
Comments
Post a Comment