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. REST adapter also supports encrypted data in the request header. 

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 headers 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 headers element. 

Sample REST adapter request with encrypted data in the headers element

<request>
{
  "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

<rest-adapter-request>
 <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>
</rest-adapter-request>

The following figure shows the sample adapter request with encrypted content type specified in the <header> element. 

Sample adapter request with encrypted content type specified in the <header> element

<request-data>
 <rest-adapter-request>
   <headers>
     <EncryptedData xmlns="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Content">
       <CipherData>
         <CipherValue>jl6mTKsDBpcbugK8mgNrpbqbrLzU7OKljcZl0UxOfp5bHw/yvoikD+j6p/bzLD9JyCkMKkuAR+Bu+pIsf98WIrqz/X0xe8F++RwpPnz1xgKwvG7X1hAHevXcIp1AxiD3i1hauoGvl5zgFO7NGFgREZVSjHqk55LGm2gfICBXRSIZU6pHtKqrs9EWBEDXua89Bxm/+eRK0Q1EksglWfpQa00hD6q7VFgfx62arJTXiLXVOeoBO0jf+FrxtmIq5UBObGgrRJXdOwYSf8jqgIG+JE/wFhfmkkE+BytAv1DlGpOlFAEFHvF93CaqFEN1D+MACfScHn+ilGEpMayAn2f8qSSnqh9OrHtWivv3D2zDKvtvXP5uPCLrk3ZB7l26TAPbzNSCAvvjeniDRv7n9S2zqb7BftNTyHOwgUAaTl53KzgxqE4EwP7XPNWvGVL7gQH+</CipherValue>
       </CipherData>
     </EncryptedData>
   </headers>
   <body>{
  "username" : "aUser",
   "password": "aPass"
}</body>
 </rest-adapter-request>
</request-data>


Related topics

REST-adapter-request-and-response-for-the-GET-action

REST-adapter-request-and-response-for-the-POST-action

REST-adapter-request-and-response-for-the-PUT-action

REST-adapter-request-and-response-for-the-DELETE-action

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*