How do I get access to the raw body in a webhook?

I need the raw text for the body in my webhook, even thought the data is structured as json and the content-type header is set to application/json.

Why? Because I get the webhook call from coral talk:

Once you’ve configured a webhook endpoint in Coral, you will receive updates from Coral when those events occur. These will be in the form of POST requests with a JSON payload consisting of the schema represented below.

They create a signature of the whole body and add the signature to the header X-Coral-Signature.

I can’t verify the signature if the body text is converted into a json object. Even if I convert back the json object to raw text, it is very likely the text won’t be the same. And for the signature verification to work, the text must be exactly the same.

I did a curl call to demonstrate this:

curl -H "content-type: application/json" -X POST -d '{"c": "charlie", "a": "alice", "b": "bob"}' https://example.com/api/v1/webhooks/abc123

Note that “c” is the first key.

When I look active pieces, I get:

As you can see, I don’t have access to the raw body text but instead the raw body text is converted to a json object and “c” is not the last key instead of the first. This is normally what you would want to do but not when verifying signatures.

Is there a way to get the raw body data?

I can’t change the way the webhook is called by coral so I need to do this in active pieces.

Hello @samuelskanbergetc ,Welcome to the community :wave:,

Currently, the webhook piece is only capable of capturing payloads in JSON format and doesn’t support raw format.

Tracking the issue at Access to rawBody from request. · Issue #3230 · activepieces/activepieces · GitHub

Thanks for the reply! OK, good to know :slight_smile:

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