Written by

Question Yone Moreno · Aug 11, 2020

How could we retrieve REST body?

Hello,

We would need to get the body from a REST message.

How could we do that in a service?

Could you provide an example, please?

We have read:

https://community.intersystems.com/post/restful-way-data-transfer

Comments

Yone Moreno  Aug 12, 2020 to Eduard Lebedyuk

Hello Eduard

We would need to be able to send a REST POST meesage with the following body:

{
"provider":"provider",
"group""group",
"location""location",
"data""data",
"checkin""checkin",
"client""client",
"admin""admin",
"apiUrl""apiUrl"
}
 
 

And get the previous body inside our Service.

We have written as a Service:

Class Servicios.REST.HistoriaClinica.Videoconsulta Extends Ens.BusinessService
{ Parameter ADAPTER = "EnsLib.HTTP.InboundAdapter"; Method OnProcessInput(pInput As %RegisteredObject, Output pOutput As %RegisteredObject) As %Status
{
do ..enviarCitaCrearSala(pInput,.pOutput)
quit $$$OK
} Method enviarCitaCrearSala(pInput As %Stream.Object, Output pOutput As %Stream.Object) As %Status
{
//TODO: Get body


set tSC = ..SendRequestSync("Videoconsulta",body,.objetoSalida)
set claseAux = ##class(%ZEN.Auxiliary.jsonProvider).%New()
set tSC = claseAux.%WriteJSONStreamFromObject(.pOutput,.objetoSalida,,,,"aeloqtuw")

Quit tSC
}
0