How to set URL for a httpRequest send via SendFormArray()?

How do I set an URL when I post a httpRequest via SendFormArray of my Ensemble Business Operation. Here is my code: 

Class CareHome.RestApiClient Extends EnsLib.REST.Operation
{

Parameter INVOCATION = "Queue";

Method Login(pRequest As CareHome.Request.LoginRequest, Output pResponse As Ens.StringResponse)
{

set tURL = ..Adapter.URL_"login/login"


set httpRequest = ##class(%Net.HttpRequest).%New()
 set httpRequest.ContentType="application/json"
 do ..ObjectToJSONStream(pRequest,.jsonStream,"aeliw")
 set httpRequest.EntityBody = jsonStream
  
 set tSC = ..Adapter.SendFormData(.tHttpResponse,"POST",httpRequest)

 set pResponse = ##class(Ens.StringResponse).%New()
 set pResponse.StringValue = tHttpResponse.Data.Read()

}

So, I am setting a tURL (which differs per REST operation) but I don't know how to include it in the SendFormData(). I have tried using an alternative function such as PostUrl() but in that function I cannot include the ContentType.

  • 0
  • 0
  • 304
  • 0
  • 1

Answers

I figured out there is a function called SendFormDataURL where you can include the tURL as the first parameter:

set tURL = ..Adapter.URL_"login/login"

set httpRequest = ##class(%Net.HttpRequest).%New()
    set httpRequest.ContentType="application/json"
    do ..ObjectToJSONStream(pRequest,.jsonStream,"aeliw")
    set httpRequest.EntityBody = jsonStream
    
    set tSC = ..Adapter.SendFormDataURL(tURL,.tHttpResponse,"POST",httpRequest)