Using secure iparams on a PUT request

Hello everyone, i’m currently working on an app that needs to update a custom field in the ticket properties and i found that the API call that can just do that is a PUT request. However, it seems like the Request method does not support PUT requests and i need to provide basic auth to the call in order to perform it. I ran a test on Postman using the PUT request and was succesful doing so but i don’t know how to perform this call in an app using secure iparams or if that’s possible at all.

This is the api call in the doc

Is there a workaround for this or should i just not use iparams and instead use a library that supports PUT requests?

Hi, @Pavel_ACL!

What is the ticket type you are trying do update?
As for now, “Service Request” tickets cannot be updated.
Look at my answer in this thread: https://community.developers.freshworks.com/t/unable-to-update-service-request-custom-fields-from-backend-code/1389/9

Now, if you are trying to update a “Incident” ticket, it should work.
If it’s the case, please, post your code here.

2 Likes

Request method do support PUT request.

Here’s the sample code where an incident type ticket’s priority is updated:
This code can be used in a Front end app.

    var headers = {
      'Authorization' : "Basic <%= encode(iparam.apikey) %>", //apiKey is the name of my secure iparam variable containing API key of my Freshservice account
      'Content-type'  : 'application/json'
    };
    var body = {
      "priority": 3
    };
    var options = { headers: headers, body: JSON.stringify(body) };
    var url = "https://{domain}.freshservice.com/api/v2/tickets/{ticket_id}";
  
    client.request.put(url, options).then(function (data) {   
      console.log(data);                         
    })
    .catch(err => {      
      console.log(err);
    });

Let me know if this answers your query.