var headers = {"Authorization": "Basic <%= encode(iparam.api_key) %>"};
var options = { headers: headers, body: "Hello world"};
var url = "https://newaccount1633786790718.freshdesk.com/api/v2/tickets/6.json";
client.request.put(url, options).then (
function(data) {
console.log(data);
},
function(error) {
console.log(error);
});
I saw other solutions in the forum like reauthenticate the credentials but not worked for me,
Tried another code
var headers = {"Authorization": "Basic <%= encode(iparam.api_key) %>"};
client.request.put("https://newaccount1633786790718.freshdesk.com/api/v2/tickets/6",{'name':'hello'},headers).then (
function(data) {
console.log(data);
},
function(error) {
console.log(error);
});
Above code throws the error like **staus:401, headers: {…}, response:
'{"code":"invalid_credentials","message":"You have to be logged in to perform this action."}', attempts: 1, errorSource: 'APP'}
checked with “whitelisted-domains” in the manifest file but error not solved
Hi @yashwanth_balanagu
Hope you are safe.
Please rewrite your code in the following way and check
let data = { "name":"hello"}
let response = await client.request.put("https://newaccount1633786790718.freshdesk.com/api/v2/tickets/6",{
headers: { Authorization: "Basic <%= encode(iparam.api_key) %>", "Content-Type": "application/json"},
body: JSON.stringify(data)
});
console.log(response);
Let me know if it doesn’t work
Regards,
Mughela Chandresh
4 Likes
Saif
(Saif Ali Shaik)
October 19, 2021, 9:15am
3
2 Likes
//Inserted code
let data = { "name":"hello"}
let response = await client.request.put("https://newaccount1633786790718.freshdesk.com/api/v2/tickets/6",{
headers: { Authorization: "Basic <%= encode(iparam.api_key) %>", "Content-Type": "application/json"},
body: JSON.stringify(data)
});
Result:- App.js:32 Uncaught (in promise) {response: ‘Error while substituting the templates’, status: 400, headers: {…}, errorSource: ‘APP’}
Result:- App.js:32 Uncaught (in promise) {response: ‘Error while substituting the templates’, status: 400, headers: {…}, errorSource: ‘APP’}
Coming error @Saif suggested by @Mughela_Chandresh
Saif
(Saif Ali Shaik)
October 20, 2021, 4:32am
6
One of the things that can help us make progress is by looking into the logs. As you make this API call, can you share the fdk.log file that is generated? — Especially those log lines that indicate this API call is being made.
See how fdk.log helps in troubleshooting
Copy specific section of logs using Debug Mode
Share browser logs if you think those can help.
Also, do you mind sharing you iparams.json
?
1 Like
Raviraj
(Raviraj Subramanian)
October 27, 2021, 12:12pm
7
Could you ensure a couple of things?
The domain has to be whitelisted by adding the domain part alone to the manifest.json file in the app root directory under the “whitelisted-domains” property. You can check the example .
The “api_key” should be an installation parameter key in your iparams.json file and it has been filled with value on the local testing page or tried end-to-end local testing by navigating to the Apps page in the Freshworks Product. The steps can be found here .
The error could most probably be caused by the second point. Could you check if you have the right installation parameter in your app and fill its value in either simulation way?
If you could share the contents of your iparams.json file, we can help you out as well.
Raviraj
(Raviraj Subramanian)
November 26, 2021, 4:21pm
8
Thanks for sharing the app source code over the Personal Message thread.
Summarizing here for future visitors.
The code has been adopted from somewhere and the api_key
is expected from the installation parameters in the app.
The app source code actually had freshdesk_api_key
as the installation parameter to get the Freshdesk’s API key from the user.
So changing the installation parameter’s name in the Authorization
request header fixed the issue.
2 Likes
system
(system)
Closed
December 2, 2021, 10:22pm
9
This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.