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

Class Mandrill.RestApiClient Extends EnsLib.REST.Operation
{

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;

ID:3244
Type:Error
Text:ERROR <Ens>ErrException: <INVALID OREF>zPing+9^Mandrill.RestApiClient.1 -- logged as '-' number - @' set pResponse.StringValue = tHttpResponse.Data.Read()'
Logged:2017-03-15 22:07:01.483
Source:Mandrill.RestApiClient
Session:1988
Job:18871
Class:Mandrill.RestApiClient
Method:MessageHeaderHandler
Trace:(none)
Stack:
  • $$^zGetErrorTrace+3^Ens.Util.Trace.1 +1
  • DO^zLogNoTrace+10^Ens.Util.Log.1 +1
  • DO^zLog+2^Ens.Util.Log.1 +1
  • DO^zLogStatus+4^Ens.Util.Log.1 +1
  • $$^zMessageHeaderHandler+68^Mandrill.RestApiClient.1 +2
  • $$^zOnTask+42^Ens.Host.1 +1
  • DO^zStart+62^Ens.Job.1 +2

 

')+'

'; 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;

ID:3245
Type:Error
Text:ERROR <Ens>ErrFailureTimeout: FailureTimeout of 15 seconds exceeded in Mandrill.RestApiClient; status from last attempt was ERROR <Ens>ErrException: <INVALID OREF>zPing+9^Mandrill.RestApiClient.1 -- logged as '-' number - @' set pResponse.StringValue = tHttpResponse.Data.Read()'
Logged:2017-03-15 22:07:11.504
Source:Mandrill.RestApiClient
Session:1988
Job:18871
Class:Mandrill.RestApiClient
Method:MessageHeaderHandler
Trace:(none)
Stack:
  • $$^zGetErrorTrace+3^Ens.Util.Trace.1 +1
  • DO^zLogNoTrace+10^Ens.Util.Log.1 +1
  • DO^zLog+2^Ens.Util.Log.1 +1
  • DO^zLogStatus+4^Ens.Util.Log.1 +1
  • $$^zMessageHeaderHandler+198^Mandrill.RestApiClient.1 +2
  • $$^zOnTask+42^Ens.Host.1 +1
  • DO^zStart+62^Ens.Job.1 +2

 

 

Vote up!
Vote down!

Rating: 0

Comments

Check  ..Adapter.URL_"users/ping.json" - it does not seem to answer (you're getting timeout error).

Vote up!
Vote down!

Rating: 0

1 answer

Answer

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!

Vote up!
Vote down!

Rating: 0

Log in to answer