Headquarters API reject not adding comments

I use a function d declare some variables and building my API string to execute in Shell script. Recently the accept stopped working and I was advised to use the “PATCH” method. It works fine and I updated my function accordingly. My HQ reject API call using the same function and is executing fine but does not add the comments I specify when I reject the questionnaire using the API.
The function I use is:
function set-status {
[Parameter(Mandatory = $true)]$baseurl,
[Parameter(Mandatory = $true)]$interviewid,
[validateset(‘reject’, ‘approve’, ‘hqreject’, ‘hqapprove’, ignorecase=$false)][string]$command,
$url = $baseurl + “/interviews/” + $interviewid + “/” + $command
$msg = @{
Comment = $comment
Invoke-RestMethod -Uri $url -Method PATCH -Body $msg -Credential $credential

The shellscript command executed uses this function above and looks like this:

set-status -baseurl “http://xx.xxx.xxx.xxx:xxxx/api/v1” -interviewid “720f7ece54894ff0893b83f6990a9494 " -command hqreject -comment"HholdfinalRCnotcompletedbyDSC*” -credential $cred

Could you please guide me asto why my comments are not recorded when I execute the API

Kind regards

Hi, Dannie.

As far as I can see from api docs - https://demo.mysurvey.solutions/apidocs/index#!/Interviews/Interviews_Reject
You need to specify comment inside of querystring not in request body.

Don’t forget to url encode comment

$encodedComment = [System.Web.HttpUtility]::UrlEncode($comment)
$url = $baseurl + "/interviews/" + $interviewid + "/" + $command + "?comment=$encodedComment " 
1 Like