Can't get REST operation to work
I am relatively new to ensemble, but I am trying to build a REST operation using the enslib.Rest.Operation but I can't seem to get it to work at all. I am completely at loss here because the errors I am receiving are very unclear. I have tried a few different variants using PostURL and SendFormDataArray but I got errors on all variants. Suggestions are welcome.
The call I am trying to product is a simple ping message to the Mandrill APIat https://mandrillapp.com/API/1.0/users/ping.json (for more details see: https://mandrillapp.com/api/docs/users.JSON.html#method=ping).
The code for my business operation is included below. In the ensemble production I have set the HTTP Server to https://mandrilapp.com and the URL to /api/1.0/. In the method the tURL is successfully to https://mandrillapp.com/API/1.0/users/ping.json
{
Parameter INVOCATION = "Queue";
Method Ping(pRequest As Ens.StringRequest, Output pResponse As Ens.StringResponse) As %Status
{
set messagestring = "{""key"": ""MyKey""}"
set tURL = ..Adapter.URL_"users/ping.json"
set tSC = ..Adapter.PostURL(tURL,.tHttpResponse,,messagestring)
set pResponse = ##class(Ens.StringResponse).%New()
set pResponse.StringValue = tHttpResponse.Data.Read()
Quit $$$OK
}
XData MessageMap
{
<MapItems>
<MapItem MessageType="Ens.StringRequest">
<Method>Ping</Method>
</MapItem>
</MapItems>
}
}
This is the errors I receive:
Visual Trace
Visual Trace
')+'
'; content += ''; return content; }, "modalShow": function() { // add ensExceptionModalGroup to class for floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div) div.className += ' ensExceptionModalGroup'; } // override default behaviour -- user must make a choice var mouseTrap = document.getElementById('zenMouseTrap'); if (mouseTrap) mouseTrap.onmouseup = null; }, "modalDelete": function() { // clean up floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div && div.parentNode) { div.parentNode.removeChild(div); } } } } window.zenUserExceptionHandler = EnsException.exceptionHandler;
|
')+'
'; content += ''; return content; }, "modalShow": function() { // add ensExceptionModalGroup to class for floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div) div.className += ' ensExceptionModalGroup'; } // override default behaviour -- user must make a choice var mouseTrap = document.getElementById('zenMouseTrap'); if (mouseTrap) mouseTrap.onmouseup = null; }, "modalDelete": function() { // clean up floating div var modalGroup = EnsException.modalGroup; if (modalGroup) { var div = modalGroup.getFloatingDiv(); if (div && div.parentNode) { div.parentNode.removeChild(div); } } } } window.zenUserExceptionHandler = EnsException.exceptionHandler;
|
Check ..Adapter.URL_"users/ping.json" - it does not seem to answer (you're getting timeout error).
I have found the problem.
in the configuration of the adapter I set the server address to http://mandrillapp.com. I changed it to mandrillapp.com (without http://) and it worked!