AnsweredAssumed Answered

JSON API Call - updating user records

Question asked by Bernard Welmers on Mar 14, 2018

So I am sure this would get answered quicker through Samanage Support but since the documentation for JSON API calls is lacking I want to make this searchable for people in the future

 

I am using PowerShell to run my API calls. That said the formatting etc is still JSON and everything still works the same as using the curl web calls.

 

I have a user called btest who has the following (truncated) properties from the call 

Invoke-webrequest https://api.samanage.com/users.json?email=btest@domain.com -Method GET -Headers $headers

 

{
"id": 3012951,
"name": "bernard\u0027s test user",
"disabled": false,
"title": "test user",
"email": "btest@domain.com",
"phone": "763-555-3024",
"department": null,
"reports_to": null,
"site": {
"id": 77652,
"name": "Minneapolis",
"time_zone": "Central Time (US \u0026 Canada)",
"language": "en",
"business_record": "@{id=42713; name=Default Business Hours; description=This is your initial business hours record}"
}
}

 

I am trying to update the user record with the following JSON file

{
"id" : 3012951,
"department" : {"name": "Information Technology"},
"role" : {"name": "Requester"}
}

 

I have also tried 

"department" : {"ID": "88027"}

 

neither of these have updated the user record using this call:

Invoke-webrequest -Headers $headers -ContentType 'application/json' -Method PUT -uri "https://api.samanage.com/users/3012951.json" -Body $upload

 

I know the command works since I am able to update the email addres, title, phone numbers and name. So the issue is solely with the fields that are selection based.

Outcomes