- 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-25-2015 04:48 AM
Hi Silas, the problem was actually much more simple than I thought: I tried a few options (creating the RESTMesssageV2 object myself, or using the one you configure via the UI).
The console debug information led me down the wrong path and somehow the first REST requests appeared to be "stuck" in the ECC queue. While looking at the input/output timestamps it shows they got half an hour after the REST-request was requested. (A mid server restart fixed that.)
In the end I did end up with a working script without noticing 😉 Oops, thanks for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-25-2015 11:31 AM
Glad you were able to figure it out Erik! If the REST message debugging was not as helpful to you in figuring out this issue, I'm curious if anything about the debug info could have been changed to make it more helpful? Or is something missing altogether?