Important Update: Archer Community Scheduled Maintenance on November 23–24 - New Community Launching Soon! Learn More..
2019-04-12 06:58 PM
The RESTful API Reference Guide 6.5 has the following info but there are issues. 1. if following the "note" there is not an example of what the body is supposed to look like. 2. if you choose to ignore the note you cannot execute the call by even spelling out the userid in the uri you get an error 400.
It frustrates me to no end that these guides are horribly written. The cdata examples section doesn't give you any help to build the body when going to it.
Does anyone know how this body or the uri is supposed to be setup for this to work?
Get user by ID
The Get user by ID resource retrieves a user by the specified ID.
Note: The data that this API returns is more secure when you use an Open Data Protocol (OData)
query in the request body (for more information, see Open Data Protocol (Odata). In this case you
must use the HTTP verb POST instead of GET. Also, using POST is valid only if you include the XHttp-
Method-Override:GET statement in the request header. Otherwise, POST returns an error.
Request
POST http://rsaarcher/platformapi/core/system/user/*userid*
POST http://rsaarcher/platformapi/core/system/user/1470
Request Header
Accept: application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Authorization: Archer session-id="*SessionToken"
Content-Type: application/json
X-Http-Method-Override: GET
Request Body
none
My goal is in my script is to have the script prompt with input at the beginning of the launch like below. Then have the input securely transmitted and retrieve that specific users contact info and then export the data to a file.
$archeruser = Read-Host -Prompt 'Input username to query'
#login data and call removed for example#
$api_url = $base_url + "/platformapi/core/system/user/?????"
$body = ??????????
$results_user = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Body $body -ContentType "application/json" -WebSession $sess
$results_user.RequestedObject | Out-File -Encoding utf8 -FilePath C:\ArcherUserInfo.txt
2019-04-13 12:14 AM
The Get User by Id call is expecting an integer value, but it sounds like you are wanting to get user info based on the UserName. To do this, use OData with the Get all users call...see Metadata User.
Here is a PowerShell example passing OData value in the URL to filter where UserName equals $archeruser:
$api_url = $base_url + "/api/core/system/user?`$filter=UserName eq '$archeruser'"
$results_user = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Body $body -ContentType "application/json"
$results_user.RequestedObject
To pass the OData value in the body, try this:
$api_url = $base_url + "/api/core/system/user"
$body = @{
Value = "?`$filter=UserName eq '$archeruser'"
} | ConvertTo-Json
$results_user = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Body $body -ContentType "application/json"
$results_user.RequestedObject
2019-04-13 12:14 AM
The Get User by Id call is expecting an integer value, but it sounds like you are wanting to get user info based on the UserName. To do this, use OData with the Get all users call...see Metadata User.
Here is a PowerShell example passing OData value in the URL to filter where UserName equals $archeruser:
$api_url = $base_url + "/api/core/system/user?`$filter=UserName eq '$archeruser'"
$results_user = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Body $body -ContentType "application/json"
$results_user.RequestedObject
To pass the OData value in the body, try this:
$api_url = $base_url + "/api/core/system/user"
$body = @{
Value = "?`$filter=UserName eq '$archeruser'"
} | ConvertTo-Json
$results_user = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Body $body -ContentType "application/json"
$results_user.RequestedObject
2019-04-15 12:20 PM
That worked thank you.
2019-10-22 02:44 AM
Thanks - this was exactly what I needed to make my day. :-)