Hello, I’m trying to connect my remote backend to the Forge app using invokeRemote.
I can successfully call the backend endpoint and verify the JWT token.
I’m making a POST request but when the request arrives to the backend the body is undefined.
The backend is a simple Express app and on the forge app the request looks like this
const payload = {
pageId: content.id,
};
const res = await invokeRemote('remote-backend', {
path: `/confluence`,
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
I’m logging the payload before I send it and I can see that it is not undefined.
Hi @JoseAntonioGonzalezR. Welcome to the developer community. I see you said you logged the payload before sending it, and it’s defined. Can you try sending a static test body value in the invokeRemote
call, and check your remote service, just to completely rule out any async issues on the request side?
const res = await invokeRemote('remote-backend', {
path: `/confluence`,
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: {
foo: 'bar'
}
});
Hi @nmansilla I tried that and the body is still undefined 
hi @JoseAntonioGonzalezR , are you using any middleware on the express app?
You may not be handling the parsing of the request body properly at that end.
Try making a POST to your backend from curl or some other method, not via your Forge app, and see if there is a different outcome.
Using a localhost express app tunneling with ngrok, could that be the issue?
@JoseAntonioGonzalezR I don’t think ngrok is your problem. But I also think my snippet wasn’t correct.. was missing a stringify on the body. Perhaps you already caught that, and were still running the problem.
const res = await invokeRemote('remote-backend', {
path: `/confluence`,
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
foo: 'bar'
})
});
I’d definitely check out @CaelMetcalfe’s suggestion of calling it with a REST client or curl, outside of Forge, just to rule that part out.
I tried with both stringified an unstringified versions 
But still no joy. I can call my REST endpoint with Postman with no issues 
I believe that I might be running into a similar issue. The last deployment on our Forge app is 2 months ago. At some point in the past few weeks, invokeRemote
has stopped setting headers on requests.
This is something that worked flawlessly ~2 months ago when we started building this integration. Now, as we’re trying to get customers onboard to it, it’s stopped working.
Here’s an example of the code:
invokeRemote(remoteKey, {
path: 'some-path',
method: 'POST',
headers: {
'MY_CUSTOM_HEADER': '123456'
},
body: JSON.stringify({'some': 'json'}),
});
We built this according to this documentation.
- headers: Optional custom headers that you can add to your request.
I just discovered that MY-CUSTOM-HEADER
is passed through.
While not incredibly common, underscores are valid in request headers and we have legacy reasons for using them. We will make the switch on our end, but it’s clear to me something changed in Atlassian’s configuration that introduced a rather significant breaking change. While my issue is specific to headers, I wouldn’t be surprised if there are other unintended issues.
1 Like