REST adapter request and response for the GET action
You can retrieve data from a specified URL by using the REST adapter - GET action.
You must enter the Get action in the URL field of the Properties tab for the Call Adapter activity. When you use a context item as an input for an adapter request, you must enclose the adapter request in the <request-data>
elements.
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. The adapter response is in a JSON format.
The following table describes the adapter request elements for the REST adapter with a Get action.
Elements for an HTTP adapter request with a Get action
Element | Description | Required |
---|---|---|
<adapter name> | Specifies the name of the adapter Default name of the adapter is RESTAdapter | No |
| Specifies the URL for the target page from where you want to obtain information | Yes |
| Specifies the header details for the adapter request in a JSON format
Sample header JSON
For more information, see Specifying header fields for the REST adapter. | No |
| Indicates the data type for the adapter response The adapter returns data only in the JSON format. | 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 | 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 adapter request for the GET action.
XML/JSON sample adapter request for the GET action
<rest-adapter-request>
"url" : "https://thecontactsapi.restlet.net/v1/contacts?active=true",
</rest-adapter-request>
The following figure shows the adapter response for the GET action.
Adapter response for the GET action in a JSON format
{"rest-adapter-response":{"metadata":
{"status":"success"},"status-line":
{"code":"200","reason":"OK"},"header-lines":
{"Accept-Ranges":"bytes","Content-Type":"application/json","Date":"Fri, 09 Jun 2017 09:31:15 GMT","Server":"Restlet-Framework/3.41.8","Vary":"Accept-Charset, Accept-Encoding, Accept-Language, Accept","X-Page-Count":"1","X-Page-Number":"1","X-Page-Size":"25","X-Total-Count":"5","Content-Length":"908","Connection":"keep-alive"},"message-body":[
{"id":"0e8dd830-ad98-11e6-bf2e-47644ada7c0f","firstName":"John","lastName":"Smith","birthday":152755200000,"active":true,"rank":1,"company":"0e8cedd0-ad98-11e6-bf2e-47644ada7c0f"},
{"id":"0e8e4d60-ad98-11e6-bf2e-47644ada7c0f","firstName":"Cole","lastName":"Darby","birthday":453340800000,"active":true,"rank":3,"company":"0e8cedd0-ad98-11e6-bf2e-47644ada7c0f"},
{"id":"0e8f5ed0-ad98-11e6-bf2e-47644ada7c0f","firstName":"Maggie","lastName":"Steward","birthday":334800000000,"active":true,"rank":5,"company":"0e8cedd0-ad98-11e6-bf2e-47644ada7c0f"},
{"id":"0e8fd400-ad98-11e6-bf2e-47644ada7c0f","firstName":"Kurt","lastName":"Williams","birthday":383270400000,"active":true,"rank":7,"company":"0e8c9fb0-ad98-11e6-bf2e-47644ada7c0f"},
{"id":"0e904930-ad98-11e6-bf2e-47644ada7c0f","firstName":"Tom","lastName":"Gibson","birthday":-34560000000,"active":true,"rank":9,"company":"0e8c9fb0-ad98-11e6-bf2e-47644ada7c0f"}]}}
The following figure shows the sample adapter request when the <ignore-line-break-in-response>
is set to true.
XML request for the Get action when the <ignore-line-break-in-response>
is set to false
<rest-adapter-request>
{
"ignore-line-break-in-response": "false",
"url": "http://maps.googleapis.com/maps/api/geocode/json?address=Noida"
}
</rest-adapter-request>
The following figure shows the adapter response for the GET action when the <ignore-line-break-in-response>
is set to true.
Adapter response for the GET action when the <ignore-line-break-in-response>
is set to true
[OUT5={"metadata":["success"],"status-line":
{"code":"200","reason":"OK"},"header-lines":
{"Content-Type":"application/json; charset=UTF-8","Date":"Thu, 27 Apr 2017 09:17:50 GMT","Expires":"Fri, 28 Apr 2017 09:17:50 GMT","Cache-Control":"public, max-age=86400","Vary":"Accept-Language","Access-Control-Allow-Origin":"*","Server":"mafe","X-XSS-Protection":"1; mode=block","X-Frame-Options":"SAMEORIGIN"},"message-body":{"results":[{"address_components":[
{"long_name":"Noida","short_name":"Noida","types":["locality","political"]},
{"long_name":"Gautam Buddh Nagar","short_name":"Gautam Buddh Nagar","types":["administrative_area_level_2","political"]},
{"long_name":"Uttar Pradesh","short_name":"UP","types":["administrative_area_level_1","political"]},
{"long_name":"India","short_name":"IN","types":["country","political"]}],"formatted_address":"Noida, Uttar Pradesh, India","geometry":{"bounds":{"northeast":
{"lat":28.636301,"lng":77.50256},"southwest":{"lat":28.397205,"lng":77.29369}},"location":
{"lat":28.535517,"lng":77.39103},"location_type":"APPROXIMATE","viewport":{"northeast":
{"lat":28.636301,"lng":77.50256},"southwest":
{"lat":28.397205,"lng":77.29369}}},"place_id":"ChIJezVzMaTlDDkRP8B8yDDO_zc","types":["locality","political"]}],"status":"OK"}}]
26 Apr 2017 21:17:50,897 [Current Time=Wed Apr 26 21:17:50 GMT-12:00 2017][Process Name=:RESTTesting:LineBreak] [Root Job Id=38fa5ea41d4d9470:64cc6ec3:15bae8fb7f6:-80001-1493284669805] [Job Id=38fa5ea41d4d9470:64cc6ec3:15bae8fb7f6:-80001-1493284669805][ProcessTermination=The process terminated in the completed state. The process started at 26 Apr 2017 21:17:49,821, terminated at 26 Apr 2017 21:17:50,897, and the execution took 1,076 milliseconds.]
The following figure shows the sample adapter request when the <allow-unsigned-certificate>
is set to true.
Adapter request for the Get action when the <allow-unsigned-certificate>
is set to true
<adapter-request>
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>get</request-action>
<request-data>
<rest-adapter-request>{"url":"https://jira.bmc.com/rest/api/2/issue/DRAOC-59817/comment","use-ssl-certificate":"true","install-certificate":"false","allow-unsigned-certificate":"true","headers" :{"content-type" :"application/json", "Authorization" : "Basic amppbnRhOlByZWV0eTEy"}}</rest-adapter-request>
</request-data>
</adapter-request>
The following figure shows the adapter response for the GET action when the <allow-unsigned-certificate>
is set to true.
Adapter response for the request when the <allow-unsigned-certificate>
is set to true
The following figure shows the sample XML request when the <install-certificate>
is set to true
XML request for the Get action when the <install-certificate>
is set to true
<adapter-request>
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>get</request-action>
<request-data>
<rest-adapter-request>
{
"url": "https://jira.bmc.com/rest/api/2/issue/DRAOC-60033",
"use-ssl-certificate": "false",
"install-certificate": "true",
"allow-unsigned-certificate": "false",
"return-data-format": "xml",
"headers": {
"authorization": {
"type": "basic",
"Username": "jjinta",
"Password": "fghrbvs"
}
}
}
</rest-adapter-request>***MASKED***</request-data>
</adapter-request>
The following figure shows the adapter response when the <install-certificate>
is set to true
Adapter response for the GET action when the <install-certificate>
is set to true
The following figure shows the sample XML request when the <download-attachment>
is set to true and the download location is specified.
XML request for the GET action when the <download-attachment>
is set to true and the download location is specified
<adapter-request>
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>get</request-action>
<request-data>
<rest-adapter-request>
{
"url": "https://jira.bmc.com/secure/attachment/137504/RequestRespose.txt",
"allow-unsigned-certificate": "true",
"return-data-format": "xml",
"download-attachment": "true",
"download-directory": "C:/jai",
"headers": {
"Authorization": "Basic amppbnRhOlByZWV0eTEy"
}
}
</rest-adapter-request>
</request-data>
</adapter-request>
The following figure shows the adapter response when <download-attachment>
is set to true and the download location is specified
Adapter response for the GET action when <download-attachment>
is set to true and the download location is specified
<rest-adapter-response>
<metadata>
<status>success</status>
</metadata>
<status-line>
<code>200</code>
<reason>OK</reason>
</status-line>
<header-lines>
<Date>Fri, 26 May 2017 05:52:57 GMT</Date>
<Server>Apache/2.4.6 (Red Hat)</Server>
<X-AREQUESTID>52x1238731x3</X-AREQUESTID>
<X-ANODEID>phx-jiraprd-05</X-ANODEID>
<X-ASEN>SEN-5981199</X-ASEN>
<Set-Cookie>JSESSIONID=709180EEFA787E5FD13C5738B4C13ABF; Path=/; Secure; HttpOnly</Set-Cookie>
<X-Seraph-LoginReason>OK</X-Seraph-LoginReason>
<Set-Cookie>atlassian.xsrf.token=BXV8-9FAB-2I0V-4AN7|7dad12ba2ede0157a9939bd4c6d82b21590c83df|lin; Path=/; Secure</Set-Cookie>
<X-ASESSIONID>18qqlxj</X-ASESSIONID>
<X-AUSERNAME>jjinta</X-AUSERNAME>
<X-Content-Type-Options>nosniff</X-Content-Type-Options>
<Content-Disposition>attachment; filename*=UTF-8''RequestRespose.txt;</Content-Disposition>
<X-Download-Options>noopen</X-Download-Options>
<Cache-control>private, max-age=31536000</Cache-control>
<Expires>Wed, 31 Dec 1969 23:59:59 GMT</Expires>
<Content-Type>text/plain;charset=UTF-8</Content-Type>
<Content-Length>10222</Content-Length>
<Connection>close</Connection>
</header-lines>
<download-directory>C:/jai</download-directory>
<name>RequestRespose.txt</name>
</rest-adapter-response>
The following figure shows the sample XML request when <enable-redirects>
is set to true.
XML request for the GET action when <enable-redirects>
is set to true
<adapter-request>
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>get</request-action>
<request-data>
<rest-adapter-request>{
"url": "http://10.129.147.45:80",
"enable-redirects": "true",
"headers": {
"authorization": {
"type": "basic",
"user-name": "Administrator",
"password": "bmcAdm1n"
}
}
}</rest-adapter-request>***MASKED***</request-data>
</adapter-request>
The following figure shows the adapter response when <enable-redirects>
is set to true.
Adapter response for the GET action when <enable-redirects>
is set to true
adapter response={"metadata":{"status":"success"},"status-line":{"code":"200","reason":"OK"},"header-lines":{"Server":"Apache-Coyote/1.1","Content-Type":"text/plain","Content-Length":"342","Date":"Fri, 12 May 2017 07:30:30 GMT"},"message-body":{"non-xml-data-response":"<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 doGet() Method of the EchoServlet, <br><br><br><br> <br><br> Query String : null<br><br><Center> Copyrights ©, Developed By XYZ <\/Center><\/Body><\/Html>"}}]
The following figure shows the sample XML request with NTLM authentication.
XML request for the GET action with NTLM authentication
<adapter-request>
<target-adapter>rest-actor</target-adapter>
<peer-location>
<location>this</location>
</peer-location>
<request-action>get</request-action>
<request-data>
<rest-adapter-request>{"url":"https://vw-pun-bao-dv01:443/hello.htm","use-ssl-certificate":"true","install-certificate":"false","allow-unsigned-certificate":"true","headers" : { "authorization" :{ "type" : "NTLM", "user-name" : "baodv01.dc\\Administrator", "password" : "bmcAdm1n" }}}</rest-adapter-request>****MASKED****</request-data>
</adapter-request>
The following figure shows the adapter response with NTLM authentication.
Adapter response for the GET action with NTLM authentication
{"rest-adapter-response":{"metadata":{"status":"success"},"status-line":{"code":"200","reason":"OK"},"header-lines":{"Content-Type":"text/html","Last-Modified":"Fri, 02 May 2014 11:08:43 GMT","Accept-Ranges":"bytes","ETag":"\"6d14b0e1f665cf1:0\"","Vary":"Accept-Encoding","Server":"Microsoft-IIS/8.0","Persistent-Auth":"true","X-Powered-By":"ASP.NET","Date":"Wed, 22 Nov 2017 08:28:51 GMT"},"message-body":{"html":{"head":{"meta":{"@name":"generator","@content":"HTML Tidy, see www.w3.org"},"title":[]},"body":{"h1":"This is NTLM test"}}}}
Comments
Log in or register to comment.