I am attempting to automate the creation of a new requester as part of our employee onboarding so that the user is associated with the department and location in FreshService using PowerShell
While I am able to create a user with the following attributes: first_name, last_name, job_title, and primary email when I go to add in the department or location value I get a status code 400 back.
I believe this has something to do with how the departments_ids variable is handling the integer, but the return error doesn’t give me much information to work off of.
$parameters = @{
first_name = "Ryan"
last_name = "Test4"
job_title = "Tester"
primary_email = "Ryan.Test4@Novinium.com"
department_ids = 11000193079
}
Try {
$WebRequestResult = invoke-RestMethod -URI https://novinium.freshservice.com/api/v2/requesters -Headers $Header -ContentType "application/json" -Method Post -Body (ConvertTo-Json $parameters) -ErrorVariable resperror
} Catch {
# Dig into the exception to get the Response details.
# Note that value__ is not a typo.
Write-Host "StatusCode:" $_.Exception.Response.StatusCode.value__
Write-Host "StatusDescription:" $_.Exception.Response.StatusDescription
}
When running that script with my API key included in the $header variable I get the following:
StatusCode: 400
StatusDescription: Bad Request
Any assistance with this would be greatly appreciated!