Facing rate-limit error when posting all conversations from one ticket to another ticket in Freshdesk using Rest API via SMI

Hello guys,
I’m trying to post all conversations from one ticket to another ticket in this process I’m receiving an error as {status: 429, headers: {…}, message: "You have exceeded the limit of 50 requests per minute", errorSource: "APP"}
Is there any alternative for posting all conversation history from one ticket to another ticket within Freshdesk?
Here I’m using SMI to fetch all conversations with pagination on button click and posting it to another ticket. Please find the below code snippet I tried

    //button click in the ticket sidebar
    $("#create").click(function () {
       var page = 1; var arr = [];
       getConvByPage(client, page, arr);
    }); 
 //Getting conversations by page
  function getConvByPage(client, page, arr) {
    var options = {
        ticketid: ticketid,
        page: page
    };
    client.request.invoke("getConversations", options).then(function (convdata) {
        console.log(convdata.response);
        var res = convdata.response;
        if (res.length !== 0) {
            for (var i = 0; i < res.length; i++) {
                arr.push(res[i])
            }
            page++;
            getConvByPage(client, page, arr);
        } else
            createInOtherTicket(client, arr);
    }, function (error) {
        console.log(error);
    });
}
//Creates conversations in other ticket
function createInOtherTicket(client, res) {
    if (res.length !== 0) {
        var count = 0;
        postNote(res, count);
        function postNote(res, count) {
            if (res[count].source !== 0 && res[count] !== undefined) {
                var options = {
                    body: res[count].body,
                    private: res[count].private
                };
                client.request.invoke("postConv", options).then(function (data) {
                    console.log(data);
                    count++;
                    console.log(count)
                    postNote(res, count);
                }, function (error) {
                    console.log(error)
                });
            } else {
                count++;
                console.log(count)
                postNote(res, count);
            }
        }
    }
}

-Soujanya.

hey @soujanya,

Hope you are doing good,

Unfortunately, Both SMI and request API are restricted to a default limit of 50 requests/min.

I am assuming that you are using $request in your server method to fetch the paginated conversations if that is the case it’s unclear from the error whether the SMI calls breached the rate limit or your server method breached the rate limit.

But based on the endpoint(conversations), it’s probably your $request in the server method that’s breaching the rate limit, in that case, you can use a third-party npm module like Axios or got to replace (only inside the server method) the request API.

Hope this helps!

Stay Safe :slight_smile:

2 Likes