I have created a API in WSO2 studio integrator like below:
curl --location --request POST 'http://localhost:8290/internal/send-messages'
--header 'accept: text/plain'
--header 'Content-Type: application/json'
--data-raw '{ "bankName": "heere", "uniqueIdentifier": "445334564" }'
To pass the requests (which received from this API) toward the endpoint, I need to add two following parameters into API Header
--header 'MasterName: TOMSON'
--header 'clientName: TOM' \
TOMSON value is unique(static) and would NOT change for any user. However TOM would be change based on application username given from API Manager (there is OATH2 authentication).
How can I add a static header (Like MasterName) to a API while sending toward the endpoint
How can I understand the username of application??
You can add a static header using the header mediator[1].
<header name="MasterName" value="TOMSON" scope="transport"/>
To get the application information from the API Manager, you can enable backend JWT[2]. This will be a JWT generated with much more information regarding the request. By decoding this[3] JWT at the backend, you can get the application information with the claim http://wso2.org/claims/applicationname
.
[1] - https://ei.docs.wso2.com/en/latest/micro-integrator/references/mediators/header-Mediator/
[2] - https://apim.docs.wso2.com/en/latest/deploy-and-publish/deploy-on-gateway/api-gateway/passing-enduser-attributes-to-the-backend-via-api-gateway/
[3] - WSO2 Decode JWT
You can use header mediator to add headers
For example
<header name="miCustomHeader" value="ThisIsTheWay" scope="transport"/>
<send>
<endpoint>
<address uri="https://someRandomURL"/>
</endpoint>
</send>
It will send miCustomHeader along its value to the endpoint
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.