How to get iparam values into app.js

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

@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

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

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 :slight_smile:

Thanks

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

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

Hi @Santhosh

All the stuffs changed as you mentioned in last reply but i getting Invalid URL - Must be FQDN


Console error

@Kithiyon,
you need to change the URL little,
eg:

var url= "https://<%= iparam.domain %>.freshdesk.com/api/v2/tickets"

hope it helps :slight_smile:

Thank you @Santhosh

i got response but it’s not a json format how to i get response as a json format

can you please share the payload which you get as a response?

This is my response payload

yeah ok,
you can parse the response eg:

JSON.parse(data.response)

Thanks

Hi @Santhosh

I have one more question How to i redirect my installation page to my Sample App page

@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

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.

@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

Thank you @Santhosh

If i hardcode it’s working very well. If i append iparam values it’s not working how to solve this

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 :slight_smile:

Thanks

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