Hi! I am trying to debug my application after 2.2 become deprecated. When i make any request to external host via ‘invokeTemplate’ I always get http 400:
Error: { headers: {}, errorSource: 'APP', response: 'Bad Request', status: 400 }
I built small http server to handle and log requests, but i dont see any incoming requests from the app. So as i understand, HTTP400 is platform response.
BTW, If i run my code locally with fdk run it works fine!
My test app ID is 363539. I use external host as iparam and try to make request on onAppInstall event.
manifest.json
{
"platform-version": "2.3",
"product": {
"freshchat": {
"events": {
"onAppInstall": {
"handler": "onAppInstallCallback"
}
},
"requests": {
"sendToExternalAPI": {}
}
}
},
"engines": {
"node": "18.16.0",
"fdk": "9.6.0"
}
}
requests.json
{
"sendToExternalAPI": {
"schema": {
"method": "POST",
"protocol":"https",
"host": "<%= iparam.url %>",
"path": "/api/",
"headers": {
"Content-Type": "application/json"
}
}
}
}
iparams.json
{
"url": {
"display_name": "URL",
"description": "Please enter the url",
"type": "text",
"required": true
}
}
server.js
exports = {
onAppInstallCallback: async function (payload){
let res;
try {
res = await $request.invokeTemplate("sendToExternalAPI", {
body: JSON.stringify({payload: JSON.stringify(payload)})
});
} catch (error) {
console.error('Error:', error);
}
console.log(JSON.stringify(res));
renderData();
}
}
Can you please explain, whats wrong?