go to post Rochdi Badis · Jan 15, 2018 Never mind guys, I've added this kind of code and seems to be working I think. Set Body1 = ##class(%ZEN.proxyObject).%New() Set Body1.Test = "fiel" Set Body1.Test2 = "ttss" Set Emp= ##class(%ListOfDataTypes).%New() Do Emp.Insert(Body1) Set Body.Array = Emp Thanks
go to post Rochdi Badis · Jan 9, 2018 Hi Eduard, Not sure is I can still ask this in this current Post or I should just start a new post, but simply, given that we still have some clients running on Cache/ensemble 2008.2.6.964 and %ZEN.Auxiliary.jsonProvider is not available, is there a Patch that can be installed for JSON provider or they only option is to upgrade those clients to 2014?Thanks
go to post Rochdi Badis · Jan 8, 2018 WoooHooo, that worked, thanks Eduard.but by the way, I downloaded Cache 2017.1 and Set Request.Https=$$$YES the same syntax error !? just to mention . Thanks again Eduard for your prompt responses have a good day
go to post Rochdi Badis · Jan 8, 2018 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
go to post Rochdi Badis · Jan 8, 2018 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
go to post Rochdi Badis · Jan 5, 2018 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 "] ORSet 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
go to post Rochdi Badis · Jan 2, 2018 They are dynamic (defined via %DispatchGetProperty/%DispatchSetProperty) so you can assign any properties to %ZEN.proxyObject.That's news to me, never heard about such functionality and that's really cool and handy! does that applies only for %ZEN.proxyObject, any %ZEN objects or any other objects !? thanks
go to post Rochdi Badis · Jan 2, 2018 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