How can I update the Planning
fields in freshservice?
I tried:
# Set the API key and endpoint URL
$apiKey = "api_key"
$endpoint = "https://domain.freshservice.com/api/v2/changes/{$id}"
# Set the new planning data for the change request
$newData = @{
"change_request" = @{
"planning" = @{
"reason_for_change" = "Test change updation"
}
}
} | ConvertTo-Json
Invoke-RestMethod -Method Put -Uri $endpoint -Headers @{ "Authorization" = "Basic $($apiKey | ConvertTo-SecureString -AsPlainText -Force | Base64Encode)" } -ContentType "application/json" -Body $newData
But this is returning nothing, I also tried change_requests
instead of changes
, but that returns 404 error. Freshservice api documentation also does not give anything regarding this.
Does anyone have any idea on this?
This had me stumped, too. The Fresh Service API documentation is most definitely lacking but I was able to figure it out by making some educated guesses after retrieving existing change data from the /changes/{id} endpoint and inspecting web elements on the changes page.
Structure the request of your body as follows:
In your example, this would appear as such:
If you want to update other fields in the Planning section, you can inspect the elements on the changes page for the key to use. Right-click the header of each field, click Inspect, and reference the value of "data-field-section" in the header element's parent . The values you find here will fall under "planning_fields" in your PUTs.
Currently, it looks like the fields are referred to as follows: