This is the first time using RestAPI from PowerShell and couldn't find much help. Following is the code we are using:
$Success = "Success"
$Failure = "Failure"
$Running = "Running"
Function Update-RestAPI {
[CmdletBinding()]
param (
[Parameter()]
[String]$ItInitials,
[String]$Stepname,
[String]$Status
)
$body = @{
"itinitials" = $ItInitials
"stepname" = $Stepname
"status" = $Status
}
$body = $body | ConvertTo-Json
Invoke-RestMethod -Uri $APIupdateurl -Method 'Post' -Body $body -ContentType 'application/json'
}
We call this function as following from different functions based on the outcome of that task.
Update-RestAPI -ItInitials $apiuser -Stepname $stepname -Status $Running
Update-RestAPI -ItInitials $apiuser -Stepname $stepname -Status $Success
Update-RestAPI -ItInitials $apiuser -Stepname $stepname -Status $Failure
For the tasks we are automating, every task will have running, success or failure status.
The running status for the API call is first step in the calling function to indicate the task running has started.
Everything is working as expected but "Running" status is not getting posted to the API but Success and Failure are showing up fine. Also, this Running status only shows up for one API call(for a specific task) but for the rest of the tasks, it doesn't show up.
I am really lost here and couldn't find why the same API call function works for other status's but just for Running status.
Any help would be really grateful.
Thanks in advance.