Specifying header fields in the REST adapter
This topic describes how to specify header fields needed for a request when using the REST adapter.
Headers enable client and server to provide additional information with the request or response. The header fields are specified in the <headers> element in the adapter request and support the HTTP standard headers in a JSON format.
For example, if you want to use basic authorization for accessing the URL by using the REST adapter, you can specify the user name and password in the <header> element in the following format.
"headers": {
"authorization": {
"type": "basic",
"user-name": "myUser",
"password": "myPassword"
}
}
}
The following figure shows the sample adapter request with the authentication token specified in the <header> element.
Sample REST adapter request with <header> element
{
"url": "https://clm-aus-123456.bmc.com:38080/baocdp/rest/process/:AutoPilot-AD-Utilities:HTTP:Get",
"use-ssl-certificate": "true",
"install-certificate": "true",
"allow-unsigned-certificate": "true",
"return-data-format": "xml",
"headers": {
"Authentication-Token": "/DwG7gAAAAAAAAAASSIUSHVVSysr/3fHRkbS9sJdUeGqHdbliWdOloDrSnu7jkWffoQwQXkNhdBiCLpWVkNr+bdp5axq95My/JF0M0jDQUy/x5usraVNHAQIXYHOSa7+AHrT41dAvY87KirFf/rer4PdAmslpKSghpsWcrJ4pM0Gi+HNkriH4NxrG1wP9IcAluRs0Kaq5QMWRMfoRri8B6c3wTJhHD4XAO5PHZmvMlAhCulhRWOYvTUl+AB29Fr4hj+YWS/tjlBujWCUuJUoHpMBxPenDGNndhPxtzi19iW9uBfZtyTL3oYNcOQSPIq4+uQDKI1Qx5ZLbfqQSBhdEgHzAkeSBfcS+Zy5ePuZ+WMLYfVmoNVdNWvPvx1+Toqnd6pnGRB9jsFMijPutmpDyCb8dInwjm8st89P99AFpbF3MUAk7HF1YSkKdMGDXKBN0KxLI7FeciiP0l58yd80R3A+C2DumW8Be+hW6yB31f6hkyzx51LgisFFL0U="
}
}
</request>
The following figure shows the sample adapter request with basic authorization and content type specified in the <header> element.
Sample adapter request with basic authorization and content type specified in the <header> element
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>post</request-action>
<request-data>
<rest-adapter-request>
{"url":"https://jira.bmc.com/rest/api/2/issue","allow-unsigned-certificate":"true","headers" :{"content-type" :"application/json", "Authorization" : "Basic amppbnRhOlByZWV0eTEy"}}
<body>{ "fields": { "project": { "key": "DRAOC" }, "summary": "Testing create issue by REST Adapter", "description": "Test REST Adapter", "customfield_10001": { "id": "12004" }, "versions": [{ "id": "18602" }], "issuetype": { "name": "Bug" } } } </body>
</rest-adapter-request>
</request-data>
</adapter-request>
Related topics
REST-adapter-request-and-response-for-the-GET-action
REST-adapter-request-and-response-for-the-POST-action