- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2015 02:34 AM
Hi,
I am trying to setup a REST call to retrieve data from an internal application via the midserver. I have defined the webserver via the UI and use JS to make the call and use the predefined webservice. In the WS definition for the GET method I have set the mid server to use.
At the moment I am just interested in making the call itself and do not care yet about parsing the json response yet: I am trying it with a few lines of code to log whether the call itself was successful or not.
var r = new sn_ws.RESTMessageV2('Device42', 'get'); |
var response = r.execute(); | |
var responseBody = response.getBody(); | |
var httpStatus = response.getStatusCode(); |
gs.log(httpStatus); |
The code executes but hangs and I need to terminate it.
In the ECC queue I see an entry for every attempt I have done so far so I think the API call request gets queued for the mid server. An ECC queue entry contains the following XML as content:
<?xml version="1.0" encoding="UTF-8"?>
<parameters>
<parameter name="message_headers" value="<?xml version="1.0" encoding="UTF-8"?><fields/>"/>
<parameter name="message_parameters" value="<?xml version="1.0" encoding="UTF-8"?><fields/>"/>
<parameter name="source" value="X"/>
<parameter name="name" value="get"/>
<parameter name="rest_user" value="............."/>
<parameter name="rest_password" value="enc:...................."/>
</parameters>
On the mid server in the logs I do not see anything related to REST messages, this API end point, etc: like it did not receive this ecc queue entry at all. (I have set 'debug.logging' to true).
Doing the API call by hand using curl on the mid server works fine so connectivity from the mid server to the internal application is ok.
Any idea how I debug this any further?
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 09:25 AM
Erik, one thing I notice in the log is that the rest message appears to be null:
REST Msg Outbound - RESTMessageClient : Executing: Outbound REST Message/Method: null/get
Are you sure you're accessing the Rest message correctly by name? One thing to keep in mind, if this is part of a scoped application you might need to reference the rest message by it's scoped name e.g. "x_acme_myapp.Device42".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-18-2015 12:51 PM
Hi Erik, you can turn on the property glide.rest.outbound.debug=true to see what's happening with the request.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2015 07:30 AM
Hi Silas,
Thanks for your response. With the debug settings I get a few logging entries:
[0:00:05.373] Script completed in scope global: script
REST Msg Outbound - RESTMessageClient : Executing synchronous request
REST Msg Outbound - RESTMessageClient : Executing: Outbound REST Message/Method: null/get
HTTP Request:
GET https://X/api/1.0/buildings/all/
Basic Auth: true
Username: ********
Password: ********
Mutual Auth: false
ECC Queue: true
MID Server: nlsrvud-snp01
ECC Correlator: null
ECC Params: NONE
REST Msg Outbound - ECCRESTRequestDispatcher : Inserting into ECC Queue with details: RESTProbe get https://X/api/1.0/buildings/all/ null,mid.server.nlsrvud-snp01
REST Msg Outbound - ECCRESTRequestDispatcher : Inserting into ECC Queue with payload: <?xml version="1.0" encoding="UTF-8"?><parameters><parameter name="message_headers" value="<?xml version="1.0" encoding="UTF-8"?><fields/>"/><parameter name="message_parameters" value="<?xml version="1.0" encoding="UTF-8"?><fields/>"/><parameter name="source" value="https://X//api/1.0/buildings/all/"/><parameter name="name" value="get"/><parameter name="rest_user" value="********"/><parameter name="rest_password" value="enc:X=="/></parameters>
REST Msg Outbound - RESTMessageClient : Response: com.glide.rest.outbound.ecc.ECCRESTResponse@f82f0dECC Output:
Output Queue SysId: c611e0700f828e00661b7f5ce1050e76
Timeout (seconds): 300
Time: 0:00:00.136 id: tomtomdev_1[glide.18] for: (SELECT ecc_queue00010.`sys_id`, 'ecc_queue0001' AS `sys_table_name` FROM ecc_queue0001 ecc_queue00010 WHERE ecc_queue00010.`response_to` = 'c611e0700f828e00661b7f5ce1050e76') UNION ALL (SELECT ecc_queue00020.`sys_id`, 'ecc_queue0002' AS `sys_table_name` FROM ecc_queue0002 ecc_queue00020 WHERE ecc_queue00020.`response_to` = 'c611e0700f828e00661b7f5ce1050e76') UNION ALL (SELECT ecc_queue00030.`sys_id`, 'ecc_queue0003' AS `sys_table_name` FROM ecc_queue0003 ecc_queue00030 WHERE ecc_queue00030.`response_to` = 'c611e0700f828e00661b7f5ce1050e76') UNION ALL (SELECT ecc_queue00040.`sys_id`, 'ecc_queue0004' AS `sys_table_name` FROM ecc_queue0004 ecc_queue00040 WHERE ecc_queue00040.`response_to` = 'c611e0700f828e00661b7f5ce1050e76') UNION ALL (SELECT ecc_queue00050.`sys_id`, 'ecc_queue0005' AS `sys_table_name` FROM ecc_queue0005 ecc_queue00050 WHERE ecc_queue00050.`response_to` = 'c611e0700f828e00661b7f5ce1050e76') UNION ALL (SELECT ecc_queue00060.`sys_id`, 'ecc_queue0006' AS `sys_table_name` FROM ecc_queue0006 ecc_queue00060 WHERE ecc_queue00060.`response_to` = 'c611e0700f828e00661b7f5ce1050e76')
*** Script: 404
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 09:25 AM
Erik, one thing I notice in the log is that the rest message appears to be null:
REST Msg Outbound - RESTMessageClient : Executing: Outbound REST Message/Method: null/get
Are you sure you're accessing the Rest message correctly by name? One thing to keep in mind, if this is part of a scoped application you might need to reference the rest message by it's scoped name e.g. "x_acme_myapp.Device42".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-21-2015 09:27 AM
Also, you did get a response back from the server, it's a 404. The reason it "hangs" is because it has to wait to be picked up by the MID server which I believe will poll for work every 15 seconds. Note that if you don't care about the response i.e. if it's a fire and forget kind of request, you can send the request with .execute() and then don't call any method on the response like getBody or getStatus -- those will cause the client to block waiting for the response.