Hi @Kithiyon ,
I have gone through the HAR logs, however, I don’t see any 502 in the logs shared. Could you please share the logs with the error specified?
Regards,
Thakur
Hi @Kithiyon ,
I have gone through the HAR logs, however, I don’t see any 502 in the logs shared. Could you please share the logs with the error specified?
Regards,
Thakur
Thank you @Thakur_Ganeshsingh
I little confused here. This event triggers when i update tickets in my freshdesk account so which browser tab i should send? ticket page in my fresh desk account or installation page .
It will be tickets page in your Freshdesk account tab
Here i shared HAR file for your reference
Network_Archive [23-02-06 12-04-45].log (61.9 KB)
This is my logs in installation configuration page
This is my server.js code
Hi @Kithiyon ,
The code and logs look good, theres nothing wrong as such.
Could you please share fdk logs if possible?
NODE_DEBUG=fdk fdk run
Regards,
Thakur
Thank you @Thakur_Ganeshsingh
Where i will get fdk logs
I executed this NODE_DEBUG=fdk fdk run in command prompt i get
‘NODE_DEBUG’ is not recognized as an internal or external command,
operable program or batch file.
I have fdk.log file in my log folder are you mention this one?
Yeah, could you please share the FDK logs?
The logs are also clean except the part where it says using deprecated version of FDK. Could you please try updating the fdk version?
@devrels - inputs?
Regards,
Thakur
I updated my fdk version. i currently using 8.6.7
node version v14.21.2
Still i facing same issue
It looks like the iparam named domain
provides the fully-qualified domain name (FQDN) and not just the subdomain. (Notice the URL mentioned in the original screenshot at Feb 2, 2023, 2:10:42 PM.)
Change the url
variable’s assignment to:
let url = `${domain}/api/v2/tickets`;
Thanks @kaustavdm
I completely missed that. Good observation.
@Kithiyon - The URL generated is https://******.freshdesk.com.freshdesk.com/api/v2/tickets
hence it is throwing 502.
Regards,
Thakur
Thank you @Thakur_Ganeshsingh @kaustavdm
Me also, I changed my code as you mentioned in last post. i getting
That log is truncated, @Kithiyon, so you don’t see the response
. You need to call data.response
to access the response. The object returned from $request.get(url, options)
has these properties:
status
: HTTP status code. number
headers
: HTTP headers. object
with each response header as key with its corresponding value.response
: The HTTP response body as a string.(I assumed you had fixed this so I did not suggest this earlier)
Your code screenshot has mixed async...await
with .then()
Promise chaining. You should rewrite the function using one of the following:
Option 1:
exports = {
onTicketUpdateCallback: function (args) {
// ... rest of the code
$request.get(url, options)
.then(function (data) {
// success handler
}, function (error) {
// error handler
});
}
}
Option 2:
exports = {
onTicketUpdateCallback: async function (args) {
// ... rest of the code
try {
const res = await $request.get(url, options);
// Add success condition here
} catch (err) {
// Error handler
}
}
}
Thank you @kaustavdm @Thakur_Ganeshsingh
I have one more doubt. I want to send outbound mails so i make api request to this api end point but email not triggered.
I getting 400 bad request error.
I’m not sure my request payload is correct or not .
This is my server.js code
var btoa = require('btoa');
exports = {
onTicketUpdateCallback: function (args) {
let status = args['data']['ticket']['status'];
let subject = args['data']['ticket']['subject'];
let priority = args['data']['ticket']['priority'];
let apprvalStatus = args['iparams']['approvalflow'];
let api_key = args['iparams']['api_key'];
let domain = args['iparams']['domain'];
let to_mail = args['iparams']['Tomail'];
let from_mail = args['iparams']['FromMail'];
let email_body = args['iparams']['body'];
console.log(api_key)
console.log(domain)
console.log(to_mail)
console.log(from_mail)
console.log(email_body)
console.log(subject)
console.log(priority)
if (apprvalStatus == status) {
console.log("i'm in IF condition");
let payload = {
"email": to_mail,
"email_config_id": from_mail,
"status": status,
"subject": subject,
"priority": priority,
" description": `<div><p>${email_body}<p><div>`,
};
let headers = {
Authorization: `Basic ${btoa(api_key + ":X")}`,
"Content-Type": "application/json"
}
let options = {
method: "POST",
headers: headers,
body: JSON.stringify(payload),
}
console.log(options)
let url = `${domain}/api/v2/tickets/outbound_email`;
console.log(url)
$request.post(url, options)
.then(
function (data) {
console.log(data.response)
},
function (error) {
console.log(error)
}
);
}
else {
console.log("not working")
}
},
};
That extra leading space in payload.description
is the likely culprit.
You should also consider using template substitutions for your iparams instead of fetching them. Check the “Using iParams” section in the Request Method documentation.
Thank you @kaustavdm It’s very helpful
I changed my code as you mentioned in last post i am able to send mail three times only then i getting 429 Too many requests error so i tried some hours later getting same error.I think i’m not reached rate limits to make api request
Hi @kaustavdm
I got something related this but i’m not sure it’s correct or not
In freshdesk account we can make totally three api calls only for onTicketupdate event so i get 429 Too many request. Then How to i increase rate limit for onTicketupdate event in my freshdesk account.
This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.