How to get req.rawBody from req.body in webtrigger Forge

I am building a Forge application which receives a webtrigger from a 3rd-party app. This app requires validating the webtrigger with headers, a pre-given public key and a rawBody. So how can I get the rawBody from the body of this webtrigger? I’ve been looking everywhere and the answers are always using “body-parser” module in node.js but this requires express.js? Then I tried to install express.js but somehow the app broke. Can anyone suggest a workaround for this? #forge

Hey @NhatNamNguyen

In the example from the docs found here https://developer.atlassian.com/platform/forge/events-reference/web-trigger/, the body of a request is passed in as a raw string to your webtrigger function.

const myWebtrigger = ({ body }) => {
    console.log(body)
}

Express JS middleware will not work on Forge as it’s designed for a long running express process. Forge functions run similar to the way a lambda function works, where the process is started and killed with the lifecycle of an HTTP request.

1 Like