HTTP integration uplink

Hi, I’m Moisés from the community of Figueres (Spain). I’m doing an http integration and I wanted to ask a question: in what variable are the raw uplink data that are published, in data? What I want to do is collect them for example in classic asp with a request.form. Can someone help me or guide me in the solution? Thank you very much in advance and sorry for my English.

Hi Moises, you can use requestbin to explore the HTTP post data
imagen
Kind regards from Madrid :wink:

imagen

Hi Juan, thanks for your quick response. I had already used requestbin, but what I can not do is save the JSON generated by the post when doing the uplink. With other APIs I save the generated data with a request.form and store them in my database. Any idea how to save the JSON? Thank you.

I don’t use asp, but for example using Node-Red you can do it with a simple template node, getting the payload_raw property
imagen

I do not use ASP so I cannot give you the concrete solution, however data coming from TTN are not like forms sent by POST: it is a JSON text file in the request body to be decoded by your asp script.

And like documented, it’s Base64 encoded:

"payload_raw": "AQIDBA==", // Base64 encoded payload: [0x01, 0x02, 0x03, 0x04]
"payload_fields": {},      // Object containing the results from the payload functions - left out when empty

See also Advantage of Base64 encoding in MQTT?

Only the raw payload; if there is a decoder, there is also a payload_fields object with already decoded fields.

Thank you very much to all. I will continue looking for the solution.

1 Like

I have found the solution: I have used Request.BinaryRead and then I write the bytes in an ADO flow object, from which the text can be read. I put the code in case someone is helpful:

<%

If Request.TotalBytes > 0 Then
Dim lngBytesCount, post
lngBytesCount = Request.TotalBytes
post = BytesToStr(Request.BinaryRead(lngBytesCount))
Response.ContentType = “text/plain”
Response.Write "Your " & Request.ServerVariables(“REQUEST_METHOD”) & " data was: " & post
End If

Function BytesToStr(bytes)
Dim Stream
Set Stream = Server.CreateObject(“Adodb.Stream”)
Stream.Type = 1 'adTypeBinary
Stream.Open
Stream.Write bytes
Stream.Position = 0
Stream.Type = 2 'adTypeText
Stream.Charset = “iso-8859-1”
BytesToStr = Stream.ReadText
Stream.Close
Set Stream = Nothing
End Function

%>

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.