We are trying to send a request to our application backend using the invokeRemote, which we added the contentType application/json in headers, added the body with JSON.stringify to our parameters, the request reaches our server after be triggered by a Jira issue update, but with no body. We tested the same request through a Resolver after clicking in a button in the UI of our Forge application and the request was sent successfully and reached the server with the body. Why this request is not working when it is called by the event trigger? Here is the function that we are trying in the event trigger:
export async function sendUpdates(event, context) {
console.log('Jira event received:', JSON.stringify(event, null, 2));
const response = await invokeRemote("remote-vk", {
path: "/integrations/jira/webhook/",
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(event),
});
if (!response.ok) {
console.error("Error forwarding webhook:", response);
}
console.log(`Forwarded to VK with status: ${response.status}`);
}
and here it is the manifest:
trigger:
- key: all-triggers
function: send-updates
events:
- avi:forge:installed:app
- avi:forge:upgraded:app
- avi:jira:updated:issue
- avi:jira:deleted:issue
function:
- key: send-updates
handler: functions/index.sendUpdates
What are we doing wrong?
1 Like
Hey @AndersonBispo
when your code runs from a product event trigger, you’re probably trying to POST a very large payload (the whole Jira event) through invokeRemote.
Forge places limits on what you can send from these async/trigger contexts, and oversized bodies can get dropped/stripped by the proxy, so your server “sees” a request with no body.
Can you check the event object, see if you can send “lighter” payload in invokeRemote.
Hey @FlixAndre , yes it is possible that the event object is too large, however, I order to test, I tried a payload very simple with only a few words like:
{"test": "test value"}
and still the server did not receive a payload in the body.
Any other idea of what can it be, @FlixAndre? We are stucked on it 
I’m really sorry, I don’t have any idea where the problem is.
Thank you for trying to help us. We will continue trying to fix it here.
Hi @AndersonBispo , I gave this a quick test myself today and I seem to be receiving the request body as apart of the invocation request. Can you please let me know what version of @forge/api you are using? Also, if you can provide me with the traceId of the request (available in the X-B3-Traceid header of the invocation request) I can have a look in our logs.
Can you also have a look at the value of the content-length header we send you?
hi @BoZhang! Here are the data that we collected when we tested it again a few minutes ago:
“@forge/api”: “^6.0.3”,
“X-B3-Traceid”:“68af045fe5524afcaa2db7b3acfc84b9”,
“Content-Length”:“”,
The payload that we tried to send in the body was just:
const response = await invokeRemote("remote-vk", {
path: "/integrations/jira/webhook/",
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ teste: "ABC" }),
});
Hey, we tried including the “Content-Length” in the header like:
const payload = { teste: "ABC" }
const response = await invokeRemote("remote-vk", {
path: "/integrations/jira/webhook/",
method: "POST",
headers: {
"Content-Type": "application/json",
"Content-Length": JSON.stringify(payload).length
},
body: JSON.stringify(payload)
});
and it worked! Thank you for your tip, @BoZhang
1 Like