Post JSON data
Options
Puneet Mathur
Member ✭
I am creating webhook end point that receives the JSON data (as post). Its header has hmac hash to validate the request.
When I receive the payload, it looks like the order in JSON is changed when received on Xano. For example the JSON posted from the external server to the Xano endpoint is:
{
"event_id": "...",
"mobile":"...",
"sdkAuthToken":"..."
}
But this when seen in debug mode is as following:
{
"mobile":"...",
"event_id":"....",
"sdkAuthToken":"...."
}
This is happening all times. Is there a sort order by any means in debug mode?
When I receive the payload, it looks like the order in JSON is changed when received on Xano. For example the JSON posted from the external server to the Xano endpoint is:
{
"event_id": "...",
"mobile":"...",
"sdkAuthToken":"..."
}
But this when seen in debug mode is as following:
{
"mobile":"...",
"event_id":"....",
"sdkAuthToken":"...."
}
This is happening all times. Is there a sort order by any means in debug mode?
Comments
-
the order typically shouldn't matter. Is it causing an error for your use-case?
-
Most systems don't guarantee the order in an object (using curly braces {}). So if you have {A: 1, B: 2, C:3} you might later render it as {C:3, A: 1, B:2}. Objects give fidelity of association, but not of sequence.
In contrast, you can have an array (using the square brackets []) that guarantee fidelity of sequence, but will lack association. [1,2,3] will continue to be [1,2,3], but its up to someone else to determine what the importance of those positions is. -
the request has a sha256 hmac which verifies the authenticity of the request.
So when I execute:
const payloadBytes = payload.getBytes();
const secretBytes = secret.getBytes();
var expectedSignature = crypto.createHmac('sha256', Buffer.from(secretBytes)).update( Buffer.from(payloadBytes)).digest('hex');
(here payload is the complete input as received)
the result is different when the sequence is not the same as sent by external server. -
Is there a way I can get the raw data which is being posted?
-
Under utility functions there is a "get raw data (webhook)" function that may help. Note that Xano is a little aggressive turning text formatted as JSON into objects that can later get re-ordered, so keep an eye on what happens with that data if you care about fidelity of sort or the integrity of the original string. (For example, the original body might be important for cryptographic validation.)
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback