Written by

Question Nezla · Jun 19

Stop HTTP Response content

Hi Guys,

below is a running a URL in a browser to connect and get live advertising packets data from Cassia AC server which keeps the connect live and keep going and population data. 

So now I'm doing the same in the below code but the issue I'm not getting anything and it gets stuck at Get(HttpURL) line because it hanging on that live connection I guess and not outputting, so how can I get the HTTP request to exit and get me only a snapshot of that data, maybe something like 20 sec worth of data?  

 BleMac="DC:0D:30:9E:3A:EC",GatewayMac="CC:1B:E0:E2:56:18"
Token=##class(SX3.Task.TemperatureCollection).GetAuth()
Set Httprequest=##class(%Net.HttpRequest).%New()
Set Httprequest.SSLConfiguration="RTLS"
Set Httprequest.Server="MyURL"
Set Httprequest.Timeout=30
Set Httprequest.Https=1
//S Httprequest.WriteTimeout=10
set Httprequest.ContentType="application/json"
Do Httprequest.SetHeader("Accept","application/json")
Do Httprequest.SetHeader("Accept-Language","en_US")
Do Httprequest.SetHeader("Authorization","Bearer "_Token)
Set HttpURL="/api/gap/nodes?filter_mac="_BleMac_"&filter_rssi=-75&mac="_GatewayMac_"&active=1&event=1&chip=1&access_token="_Token
^check("1222")=HttpURL_"|"_Token
Set tSc=Httprequest.Get(HttpURL)
^check("122")=1
^data=Httprequest.HttpResponse.Data.Read(Httprequest.HttpResponse.Data.Size)
//W !,Httprequest.HttpResponse.Data.ReadLine()
//S obj=##class(%ZEN.Auxiliary.jsonProvider).%ConvertJSONToObject(Httprequest.HttpResponse.Data.Read(Httprequest.HttpResponse.Data.Size),,.list)

Thanks

Product version: IRIS 2025.1

Comments

Julian Matthews · Jun 19

Hi Nezla.

As the URL starts out as "ac1.mqtt.sx3ac.com", suggesting that the API is using MQTT, is the %net.httprequest adapter the right way to go?

I think it'd be good to take a look at Using the MQTT Adapters to see how the adapter can be used if you haven't already.

0