Powershell REST API v3 Add-Worklog

Powershell REST API v3 Add-Worklog

Code below.

Gives response_status @{status=failed; messages=System.Object[]}

  1. $input = @"

  2. {
  3.     "worklog": {
  4.         "request": {
  5.             "id": "$RequestID"
  6.         },
  7.         "description": "Adding a worklog",
  8.         "technician": {
  9.             "name": "Test User"
  10.         },
  11.         "total_time_spent": "0 Hrs 5 Mins"
  12.     }
  13. }
  14. "@

  15. $header = @{TECHNICIAN_KEY=$ApiKey} 
  16. $params = @{input_data=$input;format='json'}
  17. $Uri = $SdpUri + "/api/v3/worklog"
  18. $result = Invoke-RestMethod -Method POST -Uri $Uri -Headers $header -Body $params -ContentType "application/x-www-form-urlencoded"
  19. $result

                  New to ADSelfService Plus?