Ahhh, I remember that, I did one before for sending emails utility.

I've created one SSL Config (just s Simple one with just s name and kept default) and my code now is :

 Set List = ##class(%ListOfObjects).%New()
 Do List.Insert(Body)
 Set Request= ##class(%Net.HttpRequest).%New()
 Set Request.Server = "devtest.altus.net.au"
 Set Request.Location = "/STP_IF/rest/Employee/Create"
 //S Request.ProxyAuthorization="SVRWSVMhME4yOlVyYW51czY="
 Set Request.Https=1
 Set Request.SSLConfiguration="TLS"
 Set Status = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, List)
 Set Status = Request.Post(,2)
but I get this error :  
{"Errors":["The request entity's media type 'text/html' is not supported for this resource."],"StatusCode":415}

and by the way, is Set Request.Https=1 correct given that  Set Request.Https=$$$YES not supported in Ensemble 2014?

 

Thanks

Hi Eduard,

I've changed the code as below (sorry, location :"/STP_IF/rest/Employee/Create") , but if I don' t provide HTTPS & SSLConfig I get the following error : "{"Errors":["HTTPS connection required."],"StatusCode":403}"

The REST API that we connecting to has no SSL configuration required, so and if I set Https=1 (because Https=$$$YES is not supported in ensemble 2014) and set Request.SSLConfiguration=""  or not setting SSLConfig at all I get this error: "SSL/TLS configuration '' is not activated."

so is there a way to get it working with SSLConfig, because in many case or programming languages SSL is rather optional?

 Set List = ##class(%ListOfObjects).%New()
 Do List.Insert(Body)
 Set Request= ##class(%Net.HttpRequest).%New()
 Set Request.Server = "devtest.altus.net.au"
 Set Request.Location = "/STP_IF/rest/Employee/Create"
 //S Request.ProxyAuthorization="SVRWSVMhME4yOlVyYW51czY="
 Set Request.Https=1
 set Request.SSLConfiguration=""
 Set Status = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, List)
 Set Status = Request.Post(,2)
 

with Request.Post() there is only brief documentation on it, so my understanding it test=1 means post to device and 2 send post and get response and not sure what rest 0 or 1 means as the doc doesn't mention it!?

and I'm guessing that location in Post method is optional given that we set Set Request.Location = "/STP_IF/rest/Employee/Create"

 

Thanks Eduard

Hi Eduard,

I thought that would the end of it but ...:)

I've created the below sample to post a JSON object but the receiving Web Service didn't receive anything ! Am I missing something!?

FYI Srever name & port are not required for this Wed Service. 

JSONPOST
 Set Body = ##class(%ZEN.proxyObject).%New()
 Set Body.Id = "123"
 Set Body.PayerEmailAddress = "email"
 Set Body.PayerBusinessHoursPhoneNumbe = "PayerBusinessHoursPhoneNumbe"
 Set Body.PayerAustralianBusinessNumbe = "PayerAustralianBusinessNumbe"
 Set Body.PayerWithholdingPayerNumber = "PayerWithholdingPayerNumber"

 Set Request= ##class(%Net.HttpRequest).%New()
 Set Request.Location = "https://devtest.altus.net.au/STP_IF/rest/Employee/"
 Set Status = ##class(%ZEN.Auxiliary.jsonProvider).%WriteJSONStreamFromObject(Request.EntityBody, Body)
 Set Status = Request.Post()

it is also a pain to look through and understand Cache documentation in many case! for example, I've some examples on JSONobjects and arrays and try to replicate them but they came up with syntax errors eg. 

SET JArray=["somthing "] 

OR

Set Array1 = ##class(%Library.DynamicArray).%New()
 SET Array1=[]

so in both cases Array1 or JArray is not understanding [] so should be including or extending a classe(s) or ...etc 
 

I'm basically looking to handcraft the  Body.%ToJSON() content to to be contained in [] so I can post it because this what Receiving Web Service is expecting the message to be like. 

so looking for somthing like : 

Set MyMessage="[" _Body.%ToJSON()_"]" 

but its not working for me at the moment!?

 

Thanks

Thank you very much Eduard that answered my question.

but what I'm puzzled about is that in my Ensemble 2014  can't find properties Prop1, Prop2...etc in %ZEN.proxyObject documentation, and also when for example Typing dot(.) after Body in my code Prop1 or Prop2 is not in the list !? and the same happens with  CopyFrom in %Net.HttpRequest, you can find Write method but not the Copyfrom method so how do we suppose to know those properties and methods? and what the Maximum Props we can have ?

set hr=##class(%Net.HttpRequest).%New()
 d hr.EntityBody.Write("Data into stream")
 do hr.EntityBody.CopyFrom(file)

 Thanks Eduard