I’m writing a serveless app.
I need to make GET, PUT and POST requests to a non-freshworks web service. I noticed the requests templates must be defined inside of a freshworks product. But I also notice that I can define a request template outside of a product and only a warning is thrown.
Let’s say I need to call GET, PUT or POST on “mywebsvc.mycompany.com”. How do I go about doing this?
Can I use request templates for this? If not, do I need to use a non-freshworks library and does anyone have recommendations?
For example, let’s say I define this request template:
"lmsGet": {
"schema": {
"method": "GET",
"host": "api-pa.mindflash.com",
"path": "/api/",
"headers": {
"Content-Type": "application/json",
"x-mindflash-Apikey": "<%= iparams.lms_api_key %>"
}
},
"options": {
"retryDelay": 1000,
"maxAttempts": 5
}
}
}
Inside manifest.json I would have this:
{
"platform-version": "2.3",
"product": {
"freshworks_crm": {
"events": {
"onContactCreate": {"handler": "onContactCreate"},
"onSalesAccountCreate": {"handler": "onAccountCreate"},
"onDealCreate": {"handler": "onDealCreate"},
"onContactUpdate": {"handler": "onContactUpdate"},
"onSalesAccountUpdate": {"handler": "onAccountUpdate"},
"onDealUpdate": {"handler": "onDealUpdate"}
}
}
},
"requests": {
"lmsGet":{}
},
"dependencies": {
"util": "0.12.4",
"googleapis": "39.2.0"
},
"engines": {
"node": "18.16.1",
"fdk": "9.0.2"
}
}
Then I invoke it with this:
$request.invokeTemplate('lmsGet', {context: {}})
This is what I get when I run fdk validate:
DataFixer> fdk validate
Please ensure that the following are addressed for quick review process:
⚠ request template 'lmsGet' is declared but not associated with any product
✔ Validation Successful
Is it valid to define request template for non-Freshdesk web services?
If I would appreciate recommendations on best practice for calling 3rd party web services from serverless apps.