Server Method Invocation - issue

hi guys,

I have been passing the secure data on to the url and getting authentication error.
By referring our community early post ([Security updates to the platform - 19 May 2021 - Announcements - Freshworks Developer Community]) i tried SMI method to render the data but i end up with an error states that

ERROR - message: “Invalid feature or feature not enabled.”

is there any alternate method to pass the secure data on to the url or something else.

Sample url am passing : **https://<%= iparam.api_key %>:<%= iparam.api_token %>@api.abc.com/v2_beta/Accounts/abcd1/PhoneNumbers**

@Raghul_Kumar,
Hope you are doing good!

can you please give more context on what you are passing on to the SMI method?
and are you passing it from Iparams or from the app?
can you please specify some code samples here for more clarity?

Thanks

@Santhosh, thank you!
** I just tried passing this sample function. and calling it on page load… after the app initialize**

function getphone() {
var options = { "url": "https://api.github.com/users/sample" };
client.request.invoke("serverMethod", options).then(
function(data) {
  // data is a json object with requestID and response.
  // data.response gives the output sent as the second argument in renderData.
  console.log("server method Request ID is: " + data.requestID);
  console.log("server method response is: " + data.response);
},
function(err) {
  // err is a json object with requestID, status and message.
  console.log("Request ID: " + err.requestID);
  console.log("error status: " + err.status);
  console.log("error message: " + err.message);
}); 
}

**and exported data on server.js file as**

exports = {
  serverMethod:  function(options) {
      // write your code here.
      // an additional key , iparam (containing account configs) will be attached to the options.
      // use renderData ( err, data ) to send back the response.
      renderData(null,  { "key": "value" });
  }
}

The code you posted seems to be fine!
Are you calling the SMI from the app page or config page?
If it’s from config page and if you are testing it end-to-end (accessing the config page in the account instead the http://localhost:10001/custom_configs), the error may be related to this: SMI from custom installation page not working on local testing - Feedback - Freshworks Developer Community
If you are calling from the app page, probably something else in your code is broken. In this case, post your actual code here, so we can try to help :wink:

2 Likes

@samuelpares @Santhosh @community-bot
we are calling SMi from app page but our app location is CTI. We getting invalid feature error.

@Raghul_Kumar,
Good Day!
The code you posted seems to be fine, possible can you please share your app zip / paste the actual code which you are trying to execute in app.js and server.js
so that we are able to find the exact root cause.

Thanks

SMI_test.zip (21.8 KB)

@Santhosh i have been attaching the sample code out here.

@Raghul_Kumar,
I had verified your app and there seems to be some issue in your folder structure,
your current folder structure is like this
SIM_TEST -> app -> scripts -> app.js, server.js

but the expected folder structure will be
for app.js
SIM_TEST -> app -> app.js
for server.js
SIM_TEST -> server -> server.js

for more reference please visit our sample app repo or sample serverless app template

Hope it helps :slight_smile:

Thanks,
Santhosh

4 Likes

@Santhosh thank you its working. :grinning:

by the way the sample app link doesn’t contain any folders on the git. (https://github.com/freshworks/marketplace-sample-apps/tree/master/Demo-Apps/twilio_sms)

@Raghul_Kumar,
Please verify this marketplace-sample-apps/Demo-Apps/twilio_sms_freshdesk at master · freshworks/marketplace-sample-apps · GitHub this contains the correct folder structure.

the link which you provide doesn’t seems to be a correct URL :slight_smile:

Yup, i took that url from freshdesk smi documentation :grinning: seems like you guys haven’t updated the documentation.

Anyways thank you @Santhosh :+1: and @community-bot :v:

3 Likes