Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 5:37am
1
Hi
I want to make API call in app.js by using iparam values. I tried some examples in documentation but it’s not working so kindly guide me to solve this issue .
This is my code to retrieve iparam values and make api call this happen when i click push button in my UI
This is my iparam.html code to get domain and apikey values from user
Santhosh
(Santhosh Balusamy)
January 13, 2023, 6:05am
3
@Kithiyon ,
It is not possible to use the template literal ( eg: Basic <%= encode(iparam.api_key) %> ) in the fetch.
I request to use requestAPI instead of fetch,
refer to this document for more references.
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 7:16am
4
Thanks for your reply,
I tried request method to fetch iparam values and make api call. I getting “Error while substituting the templates” console error
This is my code to get iparam values and api call
this is iparam.html code for iparam input box
This is my console error
Santhosh
(Santhosh Balusamy)
January 13, 2023, 8:29am
5
Are you using this in app.js (app rendering)?
are you using postconfigs in iparams?
if so, kindly verify the key is the same as the one you are using in the app.js file.
and make sure you have whitelisted the domain in the manifest.json
Hope it helps
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 9:32am
6
Yes i using app rendering
These code contents i have in app.js
This is my postconfig function in iparam.html i didn’t write any code here
This is my manifest.json file
I don’t know how to config and i want to hit freshdesk api so which domain i want to add
kindly give some code samples to solve this
Santhosh
(Santhosh Balusamy)
January 13, 2023, 10:04am
7
Instead of Iparams.html, you can use Iparams.json
copy the below snippet to iparams.json
{
"domain": {
"display_name": "domain",
"description": "Please enter your domain",
"type": "domain",
"required": true,
"type_attributes": {
"product": "freshdesk"
}
},
"api_key": {
"display_name": "api_key",
"description": "Please enter your api_key",
"type": "api_key",
"required": true,
"type_attributes": {
"product": "freshdesk"
},
"secure": true
}
}
and in the manifest
add the whitelisted-domains as
"whitelisted-domains": [
"https://*.freshdesk.com"
],
and install the app with required settings and use the app
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 10:31am
8
Hi @Santhosh
All the stuffs changed as you mentioned in last reply but i getting Invalid URL - Must be FQDN
Console error
Santhosh
(Santhosh Balusamy)
January 13, 2023, 10:35am
9
@Kithiyon ,
you need to change the URL little,
eg:
var url= "https://<%= iparam.domain %>.freshdesk.com/api/v2/tickets"
hope it helps
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 11:07am
10
Thank you @Santhosh
i got response but it’s not a json format how to i get response as a json format
Santhosh
(Santhosh Balusamy)
January 13, 2023, 11:08am
11
can you please share the payload which you get as a response?
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 11:15am
12
This is my response payload
Santhosh
(Santhosh Balusamy)
January 13, 2023, 11:21am
13
yeah ok,
you can parse the response eg:
JSON.parse(data.response)
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 13, 2023, 12:58pm
14
Hi @Santhosh
I have one more question How to i redirect my installation page to my Sample App page
Santhosh
(Santhosh Balusamy)
January 13, 2023, 8:18pm
15
@Kithiyon ,
Once the app is installed, you need to go to any of the ticket details page, and there you can find the ticket sidebar apps,
for more information, kindly go through the developers.freshdesk.com to get the full insights.
Hope it helps
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 14, 2023, 6:32pm
17
Hi @Santhosh
I Hope you are doing well…
I want to push my fresh desk tickets into github issue so i get user credentials to make API integration with Git hub.i get these credential from iparams after that i make api call to push tickets i get Bad credential error but i feed correct user credential in iparams. How to solve this ?
This is my code to make api call
iparams.json
{
"api_key": {
"display_name": "api_key",
"description": "Please enter your api_key",
"type": "api_key",
"required": true,
"type_attributes": {
"product": "freshdesk"
},
"secure": true
},
"domain": {
"display_name": "domain",
"description": "Please enter your domain",
"type": "domain",
"required": true,
"type_attributes": {
"product": "freshdesk"
}
},
"GitUserName": {
"display_name": "GitHub User Name",
"description": "Please enter GitHub User Name",
"type": "text",
"required": true
},
"GitRepoName": {
"display_name": "GitHub Repo Name",
"description": "Please enter GitHub Repo Name",
"type": "text",
"required": true
},
"Gitapi_key": {
"display_name": "Github api_key",
"description": "Please enter your GitHub api_key",
"type": "api_key",
"required": true,
"type_attributes": {
"product": "GitHUb"
},
"secure": true
}
}
This is my browser console error.
Santhosh
(Santhosh Balusamy)
January 16, 2023, 5:00am
18
@Kithiyon ,
seems like you are passing on the wrong information to GITHUB rest API,
kindly take a look at the API contract.
if you want to test, try passing a hardcoded value in the URL and Token to test the same
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 17, 2023, 4:55am
19
Thank you @Santhosh
If i hardcode it’s working very well. If i append iparam values it’s not working how to solve this
Santhosh
(Santhosh Balusamy)
January 17, 2023, 5:49am
20
you don’t need to specify the product here, (it is used only for Freshworks accounts only)
and if you are not marked as secure, you can able to access the Iparams value in the front end,
eg: client.iparams.get(),
take a look at Freshworks Developer Docs | Freshworks app ecosystem for more reference
and if it is marked as secure it won’t be available in the Frontend, and we highly recommend to mark as secure if it is sensitive info.
hope it helps
Thanks
Kithiyon
(Arokiya Kithiyon A)
January 17, 2023, 6:38am
21
I changed as you mentioned in last reply but it’s not working
This is my code to push git repository
iparam.json
{
"api_key": {
"display_name": "api_key",
"description": "Please enter your api_key",
"type": "api_key",
"required": true,
"type_attributes": {
"product": "freshdesk"
},
"secure": true
},
"domain": {
"display_name": "domain",
"description": "Please enter your domain",
"type": "domain",
"required": true,
"type_attributes": {
"product": "freshdesk"
}
},
"GitUserName": {
"display_name": "GitHub User Name",
"description": "Please enter GitHub User Name",
"type": "text",
"required": true
},
"GitRepoName": {
"display_name": "GitHub Repo Name",
"description": "Please enter GitHub Repo Name",
"type": "text",
"required": true
},
"Gitapi_key": {
"display_name": "Github api_key",
"description": "Please enter your GitHub api_key",
"type": "api_key",
"required": true,
"secure": true
}
}
outh_configuration,json
{
"client_id": "ee94474d5ebc8******",
"client_secret": "caaf6617d5a185b08284906452c2b7d34*******",
"authorize_url": "https://github.com/login/oauth/authorize",
"token_url": "https://github.com/login/oauth/access_token",
"options": {
"scope": "repo"
},
"token_type": "account"
}
1 Like