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.
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);
});