Help needed with Service Desk API managing Comments

I'm working with a PowerShell script to interact with Incidents, Tasks and Comments using the REST API. So far Incidents and Tasks have been fairly straightforward, but Comments are giving me grief.

It seems the sticking point I'm trying to solve is the "user_id" property in the request body. The doc says it can be a "number" or "string" and the example shows "1" (number one in quotes). I assume that should refer to an actual User account object?  I have a user that incidents are assigned to, but for Updating Comments, it doesn't seem to like the "name", "email" or "id" property of a user. It just throws "Request Not Acceptable".  For new Comments, it throws a different error but adds the comment with a null user_id.  Reference: apidoc.samanage.com/

$body = @{
    comment = @{
        body = "My Comment"
        is_private = $true
        user_id = "" # <== what should go here?
    }
} | ConvertTo-Json
$url = "https://api.samanage.com/incidents/123456789/comments" # incident <id> inserted
Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Headers $headers -Body $body
# adds comment but user property is empty

  • I have an update! It turns out "user_id" is incorrect. It requires "user": { "email": "<user_email>"}. That creates the Comment successfully with the correct user link, but it still throws a "406 (Not Acceptable)" error, and I have no idea what that indicates. Anyone know?

    So the modified body looks like this:

    $body = @{
        comment = @{
            body = "My Comment"
            is_private = $true
            user = @{ email = "<user_email>"}
        }
    } | ConvertTo-Json
    $url = "https://api.samanage.com/incidents/123456789/comments" # incident <id> inserted
    Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Headers $headers -Body $body
    # adds comment but user property is empty

  • Update no. 2 - using the Update option. No matter what I provide, with or without "user" or even "is_private", it throws a "406 (Not Acceptable)" error and does nothing to the Comment. If these kinds of questions should be posted elsewhere, please let me know?

  • Final comment on Comments :)  = Get, and Add (GET and POST) work as expected. Update and Delete (PUT and DELETE) do not work. This actually makes sense since comments should be immutable. However, the API docs should note that or simply not include them at all.