Thats a good suggestion.
I will check that option out and see how to use POSTMAN as a proxy. Will let you know.
Thank you Jeffrey.
- Log in to post comments
Thats a good suggestion.
I will check that option out and see how to use POSTMAN as a proxy. Will let you know.
Thank you Jeffrey.
Thanks Sourabh. I was able to put some debug variables and troubleshoot the issue.
Appreciate your help.
Regards,
Jimmy Christian
Thank you Neerav.
The message i pasted doesnt look like JSON.
Looks like i may have to use some STRING functions to parse it.
I will let you know once i get the right specs of the response. Thank you for time.
Regards,
Jimmy Christian.
Thank you Danny.
Thank you. Yes, i am going to find out in a day or two.
Appreciate your help and time.
The issue is the API is not set up yet on the project which i am working.
But the specs has the JSON PAYLOAD as request and then the response is what i pasted above.
So i am trying to get the code ready to parse in the meantime until the API is set up. Hopefully i will have something to work with POSTMAN as soon as API is set up.
Once i receive the response , i need to parse it for any error and then shutdown the operation. At the most i can convert the response to string and check for error.
Thank you Eduard.
So the message i posted is a response to an API call i make with JSON payload.
So i was assuming that the response would be JSON and i can try to parse it.
But if it is not a JSON, is there a utility to parse it or i need to use the provided STRING functions like ZSTRIP and so on?
Thanks,
Jimmy christian.
Cache for Windows (x86-64) 2018.1.1 (Build 312_1_18937U) Fri Apr 26 2019 17:58:36 EDT
I tried dynamic objects but gives me an error, unless i am not doing it correctly or if syntax is not correct.
Set json =""
While ('objStream.AtEnd) {
Set json = json _ objStream.ReadLine()
}
while iter.%GetNext(.key , .value )
{
write "key = "_key_" , value = "_value,!
}
Good Morning Danny,
I appreciate your help. After changing the names i was able to make the POST calls using SEND. Worked perfectly ! Thank you for your time.
Yes, looks like .Send has some more configurable parameters in the HttpRequest object we send.
In the same context, would you be able to know how to set a Basic Authoriztion using User and Pass while making the call ?
Seems like i have to make Credentials using ENSEMBLE.
Than set the httprequest.username and httprequest.password using that credential object.
Please let me know if you have any information.
Thank you for time.
Regards,
Jimmy Christian.
Thank you Danny for help.
Yes this worked. I did not create a seperate HttpRequest but just used the PostURL method as below.
The code you provided is very helpful. Especially when i have to include the content type while making the http request.
The Adapter object does not have that ContentType property.
By the way i am also trying to understand when to use the PostURL or .Send or
Do they provide same functionality ? If you have information and can provide me will be much appreciated.
Thank you
Jimmy Christian.
Hello Eduard,
i was able to convert the HttpResponse.Data to String and than to the Dynamic Object. Worked great. Thank you.
On the same line, i need to ask you of any template or suggestion to send a JSON data to a REST API.
For eg. below is the JSON
{"name":"abcdefghi","salary":"123","age":"23"}
How do i send it to http://testing.restapiexample.com/api/v1/createemployee with POST request using the
Below code is not working.
Your help will be appreciated.
Thanks,
Jimmy Christian.
Yes, Thank you. I just corrected the URL and it works now. Thank you Robert. One more question if you can assist in this context.
So the response message i got back is in the HttpResponse object.
How can i convert the HttpResponse.Data property to JSON and parse the values. Since the data i received is Stream, is there a way i can convert the stream to Dynamic Objects and parse it?
Thank you.
Jimmy Christian.
Thank you Marc. Looks like this Issue is resolved . Appreciate your input.
Yes, I did.
do tRequest.%Save()
set tSC = ..SendRequestAsync(..TargetConfigNames,tRequest)
Thanks,
Jimmy Christian.
Hello Eduard,
I used %Stream.FileCharacter to resolve the error on Operation which is complaining that "No Stream contained in StreamContainer Request".
I am going to use the JSON serialization once i refer to some document about it.
Thank you for help.
Jimmy Christian.
Thank you Aldo for checking this out. I tried to make it much simpler by using what you suggested. I was hoping the operation to accept it since pInput is a Stream.
But still the same error. Operation does not find STREAM in the ENS. StreamContainer.
{
Parameter ADAPTER = "EnsLib.File.InboundAdapter";
Parameter SETTINGS = "TargetConfigNames";
Property TargetConfigNames As Ens.DataType.ConfigName;
Property SentMsg As %FileCharacterStream;
Method OnProcessInput(pInput As %FileCharacterStream, Output pOutput As %RegisteredObject) As %Status
{
set tSC = $$$OK
set pInput.LineTerminator=$c(10)
try
{
while 'pInput.AtEnd {
do pInput.ReadLine()
set tRequest=##class(Ens.StreamContainer).%New(pInput)
set tSC = ..SendRequestAsync(..TargetConfigNames,tRequest)
}
Thank you Stephen. I will check the link you provided for more understanding on REST.
Hello Evgeny,
Yes this worked perfectly. I think i did select %ALL role, but did not click on assign but only SAVED it.
Thank you for all your help. But looks like at some point once i familiarize myself with this web and rest app build, i will need to learn more about security..
Thanks,
Jimmy Christian.
Thank you Nigel for the suggestions. Agreed, but since this is just a standalone training env, and for now i only want to have a hands on REST development, i think assigning %All role should be fine to see the output of the code ! Security will be my next hands on once i am familiar with the REST architecture.
Yep. Select INTO works great if the source and target tables are in same NAMESPACE. I need to copy the data across namespaces, for which i have already some another method.
But i found that copying recordset would also work, since once the object is created i can easily write to another table on a different "NAMESPACE". Only issue is to write to a target table from a recordset i need to loop it and am not aware of a straightforward copy.
Thank you Robert. But looks like i am running into another issue where data is lost and i am unable to create table.
I really would prefer to find out if there is a way to copy directly a RecordSet to a table or any other faster method rather than looping through the entire Recordset.
Vitaliy, This is great !
The code works fine now. Appreciate your help and time.
I have to put some filters on the columns now, which i think i have to use the QueryInfo Object.
Thank you !
Regards,
Jimmy Christian.
Hello Vitaliy,
Thank you for your time. This works good. Issue is that i only see the first page of the results.
Even after adding the tableNavigatorBar, it still shows only one page and not all the results. I have more than 30,000 rows to display on the page. Let me know.
Thanks,
Jimmy
I cannot share globals on the namepsace i am working on.
Actually i was able to retrieve data from Namespace2 working on a callback method for recordset which the table is using. But now issue is zenpage only shows the first page.
Will try to find out a reason why the page is hanging. It could be that i have to flip back to Namespace1 once i get the recordset.
Thanks.
Thanks Neerav.
I am referring to the zenpage call back methods, which are called on a zenpage event.
Problem is i cannot create any views in namespace2.
Thanks Neerav.
I still believe we can do in the code by using a callback method. I am not sure how to use it.
Thanks John. This was helpful. I had to correct the password for that service.
Issue is resolved.
Thank you . This is perfect !
I just tweaked it little bit
s ret=##class(%SQL.Statement).%ExecDirect(,.testingddl)
Thank you all. At this time, i will not be able to map the USER db to rest of it. But i will try to call support .
i Was able to resolve this by adding choice and display column attributes.