REST adapter request and response for the POST action
The POST action send data to a 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 table describes the elements of an REST adapter request with a POST action.
Elements of the REST adapter request with a Post action
Input element | Description | Required |
---|---|---|
<adapter name> | Specifies the name of the adapter Default name of the adapter is RESTAdapter | No |
| Specifies the target server URL to which you want to send data | Yes |
| Specifies the header details for the adapter request in a JSON format
Sample header details
For more information, see Specifying header fields for the REST adapter. | No |
<body> | Specifies the data to be posted to the target URL The
Sample format for specifying a <body> in the adapter request
Sample format for specifying <body> for a multi-part data request
| No |
| Indicates the data type for the adapter response | No |
| Determines whether to establish a secure connection | No |
| Specifies whether to allow unsigned certificates from trusted zones | No |
| Determines whether to install certificates | No |
| Specifies the Java Standard Trust Keystore passphrase Warning
| No |
| Specifies the supporting CharSet Valid values for supported languages:
| No |
| Specifies the user name required for basic or NTLM authentication specified in | No |
| Specifies the password corresponding to the user name specified in | No |
| Indicates whether to use NTLM authentication for the target server for the specified user credentials | No |
| Specifies the type of data format for HTTP content For example, application/json, multipart/form-data. | No |
| Contains the elements that specify information about the public key (X.509 certificate) and the private key that are used for the digital signature
| No |
| Specifies the file containing the private key that is used to sign the HTTP request
| Conditional; required when |
| Specifies the file containing the public key (X509 Certificate)
| Conditional; required when |
| Contains an XML file specifying the private key in an Base64-encoded PEM format | Conditional; required when |
| Contains an XML file specifying the public key (X509 Certificate) in an Base64-encoded PEM format | Conditional; required when |
| Specifies the path to the JKS that contains the client certificate | Conditional; required when |
| Specifies the password of the key contained in the JKS | No |
| Specifies the password to the JKS | Conditional; required when |
| 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 | Conditional; required when |
| Specifies whether the adapter should redirect a URL request to the changed URL location | No |
| Specifies whether the adapter should display the content of the attached file in the adapter response or save the content in a file | No |
| Specifies the full path where the attached file must be downloaded | 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 |
The following figure shows a sample XML request for the POST action for uploading content (adapter .roar file) to the TrueSight Orchestration repository.
XML request for the POST action for uploading content to the repository
<rest-adapter-request>
{
"url" : "hostname:38080/baocdp/rest/resource/upload",
"use-ssl-certificate":"true",
"install-certificate":"true",
"allow-unsigned-certificate":"true",
"headers" :{
"content-type" :"multipart/form-data" ,
"Authentication-Token":"/DwG7gAAAAAAAAANrgsfPVayj7jL3gdeA1C+s=",
"Resource-Author":"AO_USer",
"Resource-Comments":"test Comments",
"Resource-Description":"This is a test module"
}
}
<body>{
"entry": [
{
"key":"file",
"value":"C:\\module\\MyModule.0.13.roar",
"content-type":"application/octet-stream"
}
]
}
</body>
</rest-adapter-request>
The following figure shows the sample XML request for the POST action.
XML request for the POST action
<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/DRAOC-59817/comment",
"use-ssl-certificate":"false",
"install-certificate":"false",
"allow-unsigned-certificate":"true",
"return-data-format":"xml",
"headers" :{
"Content-Type" :"application/json" ,
"Authorization":"Basic amppbnRhOlByZWV0eTEy"}}
<body>{ "body": "This is a comment regarding the quality of the response." }</body>
</rest-adapter-request>
</request-data>
</adapter-request>
The following figure shows the adapter response for the POST action.
Adapter response for the POST action
<?xml version="1.0" encoding="UTF-8"?>
<ns1:XmlDoc xmlns:ns1="http://bmc.com/ao/xsd/2008/09/soa">
<value>{"rest-adapter-response":{"metadata":
{"status":"success"},"status-line":
{"code":"201","reason":"Created"},"header-lines":
{"Date":"Fri, 09 Jun 2017 08:33:42 GMT","Server":"Apache/2.4.6 (Red Hat)","X-AREQUESTID":"213x4476810x147","X-ANODEID":"phx-jiraprd-05","X-ASEN":"SEN-5981199","Set-Cookie":["JSESSIONID=B5B2EFCF567B2C9B891DBA9B81B0778E; Path=/; Secure; HttpOnly","atlassian.xsrf.token=BXV8-9FAB-2I0V-4AN7|74c1d60fe642c67b7df26b318e3fcd9abb345938|lin; Path=/; Secure"],"X-Seraph-LoginReason":"OK","X-ASESSIONID":"crkshb","X-AUSERNAME":"jjinta","Location":"https://jira.bmc.com/rest/api/2/issue/804880/comment/737565","Cache-Control":"no-cache, no-store, no-transform","X-Content-Type-Options":"nosniff","Content-Type":"application/json;charset=UTF-8","Connection":"close","Transfer-Encoding":"chunked"},"message-body":{"self":"https://jira.bmc.com/rest/api/2/issue/804880/comment/737565","id":"737565","author":{"self":"https://jira.bmc.com/rest/api/2/user?username=jjinta","name":"jjinta","key":"jjinta","emailAddress":"jeewan_jinta_tp@bmc.com","avatarUrls":
{"48x48":"https://jira.bmc.com/secure/useravatar?avatarId=10122","24x24":"https://jira.bmc.com/secure/useravatar?size=small&avatarId=10122","16x16":"https://jira.bmc.com/secure/useravatar?size=xsmall&avatarId=10122","32x32":"https://jira.bmc.com/secure/useravatar?size=medium&avatarId=10122"},"displayName":"Jinta, Jeewan","active":true,"timeZone":"America/Chicago"},"body":"This is a comment is via REST Automation.","updateAuthor":{"self":"https://jira.bmc.com/rest/api/2/user?username=jjinta","name":"jjinta","key":"jjinta","emailAddress":"jeewan_jinta_tp@bmc.com","avatarUrls":
{"48x48":"https://jira.bmc.com/secure/useravatar?avatarId=10122","24x24":"https://jira.bmc.com/secure/useravatar?size=small&avatarId=10122","16x16":"https://jira.bmc.com/secure/useravatar?size=xsmall&avatarId=10122","32x32":"https://jira.bmc.com/secure/useravatar?size=medium&avatarId=10122"},"displayName":"Jinta, Jeewan","active":true,"timeZone":"America/Chicago"},"created":"2017-06-09T03:33:48.061-0500","updated":"2017-06-09T03:33:48.061-0500"}}}</value>
</ns1:XmlDoc>
The following figure shows the sample XML request when multi-part data is specified.
XML request for the POST action when multi-part data is specified
<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://confluence.bmc.com/rest/api/content/241697462/child/attachment","allow-unsigned-certificate":"true","headers" :{ "content-type" :"multipart/form-data","Authorization":"Basic amppbnRhOlByZWV0eTEy=","X-Atlassian-Token":"nocheck"}}
<body>{"entry": [
{ "key":"file", "value":"C:\\upload.txt", "content-type":"application/octet-stream"},
{"key":"comment", "value":"This is uploaded through REST adapter", "content-type":"text/plain"}]}</body>
</rest-adapter-request>
</request-data>
</adapter-request
The following figure shows the adapter response for the POST action for a multi-part data request.
Adapter response for the POST action for a multi-part data request
{
"rest-adapter-response": {
"metadata": {
"status": "success"
},
"status-line": {
"code": "200",
"reason": "OK"
},
"header-lines": {
"Date": "Fri, 09 Jun 2017 08:33:57 GMT",
"Server": "Apache-Coyote/1.1",
"X-ASEN": "SEN-211201",
"X-Seraph-LoginReason": "OK",
"X-AUSERNAME": "jjinta",
"Vary": "User-Agent",
"Cache-Control": "no-cache, must-revalidate",
"Expires": "Thu, 01 Jan 1970 00:00:00 GMT",
"X-Content-Type-Options": "nosniff",
"Content-Type": "application/json",
"Set-Cookie": "JSESSIONID=DF45E9A931788985B5F35F4B979F6933; Path=/; HttpOnly",
"Keep-Alive": "timeout=5, max=100",
"Connection": "Keep-Alive",
"Transfer-Encoding": "chunked"
},
"message-body": {
"results": [
{
"id": "att275558874",
"type": "attachment",
"status": "current",
"title": "upload.txt",
"version": {
"by": {
"type": "known",
"username": "jjinta",
"userKey": "2c98884850f2330d0151813e23cf4550",
"profilePicture": {
"path": "/images/icons/profilepics/default.png",
"width": 48,
"height": 48,
"isDefault": true
},
"displayName": "Jinta, Jeewan",
"_links": {
"self": "https://confluence.bmc.com/rest/experimental/user?key=2c98884850f2330d0151813e23cf4550"
}
},
"when": "2017-06-09T03:33:57.264-05:00",
"message": "This is uploaded through REST Automation ",
"number": 1,
"minorEdit": false,
"_links": {
"self": "https://confluence.bmc.com/rest/experimental/content/att275558874/version/1"
},
"_expandable": {
"content": "/rest/api/content/att275558874"
}
},
"container": {
"id": "241697462",
"type": "page",
"status": "current",
"title": "AO Content Test Cases -Revisited",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/display/BAO/AO+Content+Test+Cases+-Revisited",
"tinyui": "/x/tgJoDg",
"self": "https://confluence.bmc.com/rest/api/content/241697462"
},
"_expandable": {
"container": "/rest/api/space/BAO",
"metadata": "",
"operations": "",
"children": "/rest/api/content/241697462/child",
"history": "/rest/api/content/241697462/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/241697462/descendant",
"space": "/rest/api/space/BAO"
}
},
"metadata": {
"comment": "This is uploaded through REST Automation ",
"mediaType": "text/plain",
"_expandable": {
"currentuser": "",
"properties": ""
}
},
"extensions": {
"mediaType": "text/plain",
"fileSize": 1419,
"comment": "This is uploaded through REST Automation "
},
"_links": {
"webui": "/display/BAO/AO+Content+Test+Cases+-Revisited?preview=%2F241697462%2F275558874%2Fupload.txt",
"download": "/download/attachments/241697462/upload.txt?version=1&modificationDate=1496997237264&api=v2",
"self": "https://confluence.bmc.com/rest/api/content/att275558874"
},
"_expandable": {
"operations": "",
"children": "/rest/api/content/att275558874/child",
"history": "/rest/api/content/att275558874/history",
"ancestors": "",
"body": "",
"descendants": "/rest/api/content/att275558874/descendant",
"space": "/rest/api/space/BAO"
}
}
],
"size": 1,
"_links": {
"base": "https://confluence.bmc.com",
"context": ""
}
}
}
}
Comments
Log in or register to comment.