Issue with Freshdesk CLI and Contextual Data in Third-Party API Calls

Hello Freshdesk Community,

I am currently working on developing an app using Freshdesk CLI, and I have encountered an issue regarding the usage of contextual data in third-party API calls. I hope someone here can provide some guidance or insights to help me resolve this problem.

According to the Freshdesk CLI documentation, I can declare template variables that are populated with contextual data passed through the runtime API when invoking the request template.

It is essential to ensure that the variableName used in the template matches the context variable name provided when invoking the request template through the runtime API. Unfortunately, I have found that only the variable named id seems to work successfully, while other variable names do not produce the desired results.

I have attempted to use different variable names to pass contextual data to my third-party API calls, but any name other than id causes the runtime API call to fail.

I would greatly appreciate any assistance or suggestions from the Freshdesk community regarding this issue. Has anyone else encountered a similar problem when using Freshdesk CLI? Are there any workarounds or alternative approaches that could help me incorporate contextual data correctly into my third-party API calls?

Best regards,
Harsh

Hey @Harsh_Suchak,

Can you share your requests.json file?

Context variables can be defined as -

"replyTicket": {
        "schema": {
            "protocol":"https",
            "method": "PUT",
            "host": "<%= iparam.subdomain %>.freshdesk.com",
            "path": "/api/v2/tickets/<%= context.id %>/reply",
            "headers": {
                "Authorization": "Basic <%= encode(iparam.api_key) %>",
                "Content-Type": "application/json"
            }
        }
    },

And you would be able to set the context variable name as per your needs. Is this a query parameter or a path parameter?

You can also refer - GitHub - freshworks-developers/request-method-samples: Sample codes to demonstrate making API calls using Request Method

It is a path parameter.
The below is the invokeTemplate screenshot.

image

Below is the screenshot of the API request in requests.json

Here, I used orderId when making the request as well as in the requests json file and API is not working but if I use just id then it will work. I don’t know the reason.
Anyways, I have managed to create API snapshots with just using id.

@Harsh_Suchak,

That should not be the case. As long as variable name in requests.json matches with JSON key sent in context in request.invokeTemplate() it should get substituted.

requests.json template

"path": "......./<%= context.someVariableName %>

And during request.invokeTemplate()

await client.request.invokeTemplate("templateName", {
    context: {
           "someVariableName": "value"
    }
})

What is the error you see when you change orderId to id?

Is it that only in this template id is not working as expected but the same app with a different template with id works (this should not be the case) or in different apps it works?

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