REST adapter request and response for the PUT action


The PUT action for the REST adapter sends updates to the specified URL.

When you use a context item as an input for an adapter request, you must enclose the adapter request in the <request-data> elements. However, when you create a static request, <request-data> is not required and the adapter request starts with the <restadapterrequest> element. 

Adapter requests for the REST adapter are in the JSON format. You specify the adapter name, header, and other parameters, which are converted to a JSON format. By default, the adapter response is in a JSON format. 

The following figure describes the elements of an REST adapter request with a Put action.

Elements of an REST adapter request with a Put action

Element

Description

Required

<adapter name>

Specifies the name of the adapter

Default name of the adapter is RESTAdapter

No

<url>

Specifies the target server URL to which you want to send data

Yes

<headers>

Specifies the header details for the adapter request in a JSON format

Sample header
 {
  "headers": {
     "authorization": {
        "type": "basic",
        "user-name": "myUser",
        "password": "myPassword"
      }
   }
}

For more information, see Specifying header fields for the REST adapter.

No

<body>

Specifies the data to be posted to the target URL

The <body> element accepts JSON format.

 

JSON sample for specifying the <body> element
{
   --- any json ---
}

 

Sample format for specifying <body> for a multi-part data request
{
       "entry": [
           { "key":"", "value":"", "content-type":""},
           {"key":"", "value":"", "content-type":""}
          ]
}

No

<return-data-format>

Indicates the data type for the adapter response 

The adapter returns data only in the JSON format.

No

<use-ssl-certificate>

Determines whether to establish a secure connection 

Set the value of this element to true when <action> uses HTTPS. 
Set the value of this element to false or leave it blank when <action>uses HTTP. 

Valid values: true, false (default)

No

<allow-unsigned-certificate>

Specifies whether to allow unsigned certificates from trusted zones 

Set the value of this element to true, if you are using self-signed SSL certificates (a common practice). 

Valid values: true, false (default)

No

<install-certificate>

Determines whether to install certificates 

Set the value of this element to true, if you prefer to have security certificates installed automatically (a common practice). Set the value of this element to false, if you prefer to manually export the security certificate from the specified target server and manually import it into the TrueSight Orchestration's local peer's cacerts file (a rare practice). 

Valid values: true, false (default)

No

<passphrase>

Specifies the Java Standard Trust Keystore passphrase 

Default value: changeit

Warning

 

  • The value of the <passphrase> element is the passphrase for the cacerts certificate stored on the TrueSight Orchestration local peer (CDP or AP) and not the specified target host.
  • Changing the passphrase can be tricky and might destroy the cacerts security file integrity.

Verify the cacerts passphrase using the following command in UNIX or Linux: 

$ /opt/bmc/ao/cdp/jvm/bin/keytool -list -keystore 
/opt/bmc/ao/cdp/jvm/lib/security/cacerts

No

<character-set>

Specifies the supporting CharSet 

Also called character set, it includes identifiers describing a series of universal characters. 

Note: If you do not specify the supporting character set, the adapter response is parsed based on the character set in the HTTP response header.

Valid values for supported languages:

  • Shift_JIS : Japanese character set
  • Big5 : Traditional Chinese character set
  • ISO-8859-2 : ISO character set for Central European languages.

No

<signature-properties>

Contains the elements that specify information about the public key (X.509 certificate) and the private key that are used for the digital signature 

Note: If you specify signature-properties in the adapter configuration and an adapter request, the values in the request override the values in the configuration. 

The <signature-properties> element can contain the modeattribute that specifies the format in which the public (X.509 certificate) and private keys are provided for signing the HTTP request. 

You can provide the keys using one of the following formats:

  • Java Keystore (JKS)
  • Privacy Enhanced Mail (PEM)
  • Definite Encoding Rules (DER) files
  • Base64-encoded PEM 

    Valid values:
  • <signature-properties mode="keystore"> (default)
  • <signature-properties mode="key-files">
  • <signature-properties mode="key-data">

No

<private-key-file>

Specifies the file containing the private key that is used to sign the HTTP request 

The adapter supports the following formats:

  • Base64-encoded PEM
  • DER

Conditional; required when<signature-properties mode="key-files">

<certificate-file>

Specifies the file containing the public key (X509 Certificate) 

The adapter supports the following formats:

  • Base64-encoded PEM
  • DER

Conditional; required when<signature-properties mode="key-files">

<private-key-data>

Contains an XML file specifying the private key in an Base64-encoded PEM format 

For example: 
<private-key-data> --- BEGIN PRIVATE KEY --- 
MIICdQIBADANBgkqhkiG9w0 
BAQEFAASCAl8wggJbAgEAAo 
GBAKomKro6VbW4PeQtUhNz 
ZpSH26vbBTBtH1r4EjnIv4vnh 
SyyA62ewpROVNn0Spvjo 
BFwE88HcX3tXym/zbVgtd 
Pke9K+SYHP6CWdiLqn 
... 
--- END PRIVATE KEY -</private-key-data>

Conditional; required when<signature-properties mode="key-data">

<certificate-data>

Contains an XML file specifying the public key (X509 Certificate) in an Base64-encoded PEM format 

For example: 
<certificate-data> --- BEGIN CERTIFICATE --- 
MIICdzCCAeCgAwIBAgIFXseN1xYwDQYJKoZIhvcNAQEFBQ 
AwUzELMAkGA1UEBhMCVVMxEzARBgNVBAoTCkFtYXpvbi5jb20x 
DDAKBgNVBAsTA0FXUzEhMB8GA1UEAxMY 
........ 
--- END CERTIFICATE -</certificate-data>

Conditional; required when<signature-properties mode="key-data">

<keystore-file>

Specifies the path to the JKS that contains the client certificate

Conditional; required when<signature-properties mode="keystore">

<key-password>

Specifies the password of the key contained in the JKS 

Note: If you do not specify <key-password>, then the value of<keystore-password> is used as the key password.

No

<keystore-password>

Specifies the password to the JKS

Conditional; required when<signature-properties mode="keystore">

<client alias>

Specifies the name of the alias in the JKS that identifies the Public Key Certificate (PKC) that the web server uses to authenticate the client 

Note: The value of the <alias> element is verified only when<install-certificate> is set to true and <allow-unsigned-certificate> is set to false.

Conditional; required when<signature-properties mode="keystore">

<enable-redirects>

Specifies whether the adapter should redirect a URL request to the changed URL location 

Valid values: true (default), false 

Note: If you specify <enable-redirects> in the adapter configuration and an adapter request, the values in the request override the values in the configuration.

No

<download-attachment>

Specifies whether the adapter should display the content of the attached file in the adapter response or save the content in a file 

Valid values: true, false (default) 

If <download-attachment>=true, the adapter checks the <content-disposition> field in the response header. If <content-disposition> contains attachment; file-name="abc.doc", the adapter saves the attached file. 

If the adapter response header does not contain the content-disposition field, the adapter checks the <content-type> field in the response header. If <content-type> contains an image or attachment, the adapter saves the attached file. 

If <download-attachment>=false, the content of the attached file is displayed in the adapter response.

No

<download-directory>

Specifies the full path where the attached file must be downloaded 

Default value: Temporary directory of the Java virtual machine of the peer

No

<request-timeout>

Specifies the time (in seconds) to wait when establishing a connection 

Default value: 10 seconds.

No

<ignore-line-break-in-response>

Specifies whether to ignore the line breaks while generating the adapter response

If true, the line break markups are ignored and the response is returned as a single line. If false, the line break markers (if specified in the adapter response) are retained.

Valid values: true (default), false

No

<secure-protocols>

Specifies the SSL/TLS protocols for establishing a network connection with a target server

You can specify a single string value like SSLv3 or TLSv1 or a list of protocols separated by commas.

Example: TLSv1,TLSv1.1,TLSv1.2

No

The following figure shows the sample XML request for the PUT action.

XML request for the PUT action

<adapter-request>
  <target-adapter>rest-actor</target-adapter>
  <peer-location>
     <location>this</location>
  </peer-location>
  <request-action>put</request-action>
  <request-data>
     <rest-adapter-request>
         {"url":"https://jira.bmc.com/rest/api/2/issue/DRAOC-60033","install-certificate":"true","headers" :{"Content-Type" :"application/json" ,"Authorization" : "Basic amppbnRhOlByZWV0eTEy"}}
        <body>{"fields": { "assignee":
{"name":"jjinta"}
}}</body>
     </rest-adapter-request>
  </request-data>
</adapter-request>

The following figure shows the adapter response for the PUT action.

Adapter response for the PUT action

{
  "rest-adapter-response": {
     "metadata": {
        "status": "success"
     },
     "status-line": {
        "code": "204",
        "reason": "No Content"
     },
     "header-lines": {
        "Date": "Fri, 09 Jun 2017 08:34:16 GMT",
        "Server": "Apache/2.4.6 (Red Hat)",
        "X-AREQUESTID": "214x4477384x144",
        "X-ANODEID": "phx-jiraprd-05",
        "X-ASEN": "SEN-5981199",
        "Set-Cookie": [
           "JSESSIONID=DCBCAFFD61F9A38D6452290038B2E755; Path=/; Secure; HttpOnly",
           "atlassian.xsrf.token=BXV8-9FAB-2I0V-4AN7|60bcef697b20412b5f1cf9649b9d8a69b7c8b58e|lin; Path=/; Secure"
         ],
        "X-Seraph-LoginReason": "OK",
        "X-ASESSIONID": "sxa7s8",
        "X-AUSERNAME": "jjinta",
        "Cache-Control": "no-cache, no-store, no-transform",
        "X-Content-Type-Options": "nosniff",
        "Content-Type": "application/json;charset=UTF-8",
        "Content-Length": "0",
        "Connection": "close"
     },
     "message-body": []
  }
}

The following figure shows the sample XML request when <install-certificate> is true.

XML request for the PUT action <install-certificate> is true

<adapter-request>
  <target-adapter>rest-actor</target-adapter>
  <peer-location>
     <location>this</location>
  </peer-location>
  <request-action>put</request-action>
  <request-data>
     <rest-adapter-request>
         {"url":"https://jira.bmc.com/rest/api/2/issue/DRAOC-60033","install-certificate":"true","headers" :{"Content-Type" :"application/json" ,"Authorization" : "Basic amppbnRhOlByZWV0eTEy"}}
        <body>{"fields": { "assignee":
{"name":"jjinta"}
}}</body>
     </rest-adapter-request>
  </request-data>
</adapter-request>

The following figure shows the adapter response <install-certificate> is true.

Adapter response for the PUT action <install-certificate> is true

{
  "rest-adapter-response": {
     "metadata": {
        "status": "success"
     },
     "status-line": {
        "code": "204",
        "reason": "No Content"
     },
     "header-lines": {
        "Date": "Fri, 09 Jun 2017 08:34:16 GMT",
        "Server": "Apache/2.4.6 (Red Hat)",
        "X-AREQUESTID": "214x4477384x144",
        "X-ANODEID": "phx-jiraprd-05",
        "X-ASEN": "SEN-5981199",
        "Set-Cookie": [
           "JSESSIONID=DCBCAFFD61F9A38D6452290038B2E755; Path=/; Secure; HttpOnly",
           "atlassian.xsrf.token=BXV8-9FAB-2I0V-4AN7|60bcef697b20412b5f1cf9649b9d8a69b7c8b58e|lin; Path=/; Secure"
         ],
        "X-Seraph-LoginReason": "OK",
        "X-ASESSIONID": "sxa7s8",
        "X-AUSERNAME": "jjinta",
        "Cache-Control": "no-cache, no-store, no-transform",
        "X-Content-Type-Options": "nosniff",
        "Content-Type": "application/json;charset=UTF-8",
        "Content-Length": "0",
        "Connection": "close"
     },
     "message-body": []
  }
}

The following figure shows the sample XML request with a query string in the URL. 

XML request for the PUT action with a query string in the URL

<adapter-request>
  <target-adapter>rest-actor</target-adapter>
  <peer-location>
     <location>this</location>
  </peer-location>
  <request-action>put</request-action>
  <request-data>
     <rest-adapter-request>
         {"url":"http://10.128.249.27:8080/httpclientoperations/HttpClientServlet?QueryNameAddress","allow-unsigned-certificate":"true"}
        <body>{"Put Request":"This is a put request QueryString"}</body>
     </rest-adapter-request>
  </request-data>
</adapter-request>

The following figure shows the adapter response when a query string is specified in the URL.

Adapter response for the PUT action when a query string is specified in the URL

{"rest-adapter-response":{"metadata":
{"status":"success"},"status-line":
{"code":"200","reason":"OK"},"header-lines":
{"Server":"Apache-Coyote/1.1","Content-Type":"Plain/text;charset=ISO-8859-1","Content-Length":"451","Date":"Fri, 09 Jun 2017 10:09:51 GMT"},"message-body":"<Html><Title>Testing Application for HTTP Adapter<\/Title><Head><\/Head><Title>Testing Application for HTTP Adapter<\/Title><Head><\/Head><Body>Hi, I am inside the doPut() Method of the EchoServlet, <br><br><br><br> <br><br> Query String : QueryNameAddress<br><br>QueryNameAddress <BR><BR> XML Text :
{\"Put Request\":\"This is a put request QueryString\"}<Center> Copyrights ©, Developed By Rajat Arora <\/Center><\/Body><\/Html>"}}

The following figure shows the sample adapter request with a proxy server. 

Sample adapter request with a proxy server

<adapter-request>
  <target-adapter>rest-actor</target-adapter>
  <peer-location>
     <location>this</location>
  </peer-location>
  <request-action>put</request-action>
  <request-data>
     <rest-adapter-request>
         {"url":"http://10.128.249.27:8080/httpclientoperations/HttpClientServlet"}
        <body>{"body":"This is a comment is via REST Automation"}</body>
     </rest-adapter-request>
  </request-data>
</adapter-request>

The following figure shows the adapter response with a proxy server.

Adapter response for the PUT action with a proxy server

{"rest-adapter-response":{"metadata":
{"status":"success"},"status-line":
{"code":"200","reason":"OK"},"header-lines":
{"Server":"Apache-Coyote/1.1","Content-Type":"text/plain;charset=ISO-8859-1","Content-Length":"417","Date":"Fri, 09 Jun 2017 08:34:56 GMT"},"message-body":"<Html><Title>Testing Application for HTTP Adapter<\/Title><Head><\/Head><Title>Testing Application for HTTP Adapter<\/Title><Head><\/Head><Body>Hi, I am inside the doPut() Method of the EchoServlet, <br><br><br><br> <br><br> Query String : null<br><br><BR><BR> XML Text :
{\"body\": \"This is a comment is via REST Automation.\"}<Center><\/Center><\/Body><\/Html>"}}

 

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