Using POST and GET API Methods are no longer supported

Hi there,

I have made a custom freshdesk app. That has REST API requests and responses. When I do some updates on the app and when ready run the app, I am getting post is no longer supported in Request API error message. Below I attached my API Request as well. Can anyone help me with this to fix ?

Hi @AmilaDeshan,

The Request Method syntax has been changed in the FDK version 9 onwards. Please refer to the documentation for the updated steps to make GET and POST APIs with request method definition, schema definition, and then calling the schema.

Hi @Raviraj,

Thank you for the reply. Now I changed my codes as per the documentation. but I am getting Validation Failed Error message. Please check my codes below and suggest a solution for me.

App.js File

var client;

init();
async function init() {
    client = await app.initialized();
    client.events.on('app.activated', renderText);
}

async function renderText() {
    const contactData = await client.data.get('contact');
    const {
        contact: { name, email }
    } = contactData;

    try {
        const customerBody = {
            "Filter": {
                "Email": email,
                "OutputSelector": ["Username"]
            }
        };

        const response = await client.request.invokeTemplate("getCustomer", {
            context: {
                body: customerBody,
            }
        });
        console.log('Response:', response);
    } catch (error) {
        console.error('Error:', error);
    }
}

requests.json file

Manifest.json file

Error Message
Screenshot 2023-12-14 085348

Hi @AmilaDeshan,

The code looks almost correct. Only issue I find is that body attribute defined in the schema. It’s not required to be defined in the schema.

It can be directly passed as an argument while invoking the request with the template as shown in the documentation like this.

const response = await client.request.invokeTemplate("getCustomer", {
  context: {},
  body: JSON.stringify(customerBody)
  }
});

If it fails, the error comes from the third-party service’s API response. Please find what is being missed that causes this issue and ensure it’s passed correctly from the app.
If you can make the API work in cURL or Postman and only fail in the app, it’s easier to find where it is failing.

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