Client.request.get iparam not getting applied

I’m trying to use iparam

Below is sample code. For clarity error handling has been omitted.

async function getContact() {
  var headers = {"Authorization": "Token token=<%= (iparam.crm_api_key) %>"};
  var url = "https://<%= (iparam.crm_domain) %>/crm/sales/api/contacts/" + window.contact_id;
  var res = await _asyncRequest('get', url, headers )

// Common Method to make REST API calls
const _asyncRequest = (method, url, headers, body={}) => {
  // Returns promise which can be held until complete with await (async/await model)
  return client.request[method](url, { body: JSON.stringify(body), headers: headers } )

This code works fine when I’m testing in local dev Env in Chrome using ?dev=true.

But when I publish the app to a custom app, I get 400 error with message about Fully Qualified Domain required.
Then I hard code the domain and then I get error “message”:“Incorrect or expired API key”.

Then I hard code key and it all works fine.

Just before I run the request method I use console.log to make sure values are as expected. headers and url are still as I set them with the unresolved iparam syntax. I guess this is expected since the iparam is not replaced until request hits the server?

What am I doing wrong here? I’m pulling what is left of my hair out over this!

Do you mind sharing iparams.json of both domain and API key?

No problem. here it is:

  "crm_domain": {
    "display_name": "FreshCRM Domain",
    "description": "Get this from URL field of FreshCRM (domain name only).",
    "default_value": "",
    "type": "text",
    "required": true,
    "secure": true
  "crm_api_key": {
    "display_name": "FreshCRM API key",
    "description": "Get this from FreshCRM Settings > API Key.  This is user-specific and should be changed if user is deactivated",
    "type": "text",
    "required": true,
    "secure": true

@stevemc,We recently blocked this approach of fetching iparams, it only works for headers.

for the other way, please look at this example code snippet for the appropriate usage.

 function listAllTickets() {
      var options = {
        headers: {
          Authorization: `Basic <%= encode(iparam.api_key) %>`, // substitution happens by platform
          "Content-Type": "application/json",
      client.iparams.get().then(function (iparams) {
        const URL = `https://${iparams.domain}`;
          .get(URL, options)
          .then(function ({ response }) {

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.