cancel
Showing results for 
Search instead for 
Did you mean: 

Question on API Sample Calls.

ChrisJohnson2
Contributor III

Greetings API community,

 I am new to the Archer API so please forgive the simple questions.

 

Using PowerShell and the REST API sample calls I was able to complete the basics such as set the Instance information, login and obtain a session token.  The “All Applications” call lists the applications in my instance but starts the output with a 401 error. The API account being used is local with system admin rights.

 

ERROR AT BEGINNING OF OUTPUT:

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

At C:\Users\JohCh001\Documents\All Applications.ps1:5 char:12

+ $results = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Co ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   + CategoryInfo         : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException

   + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

 

QUESTIONS:

1. Reading the instructions the header requires the session token but how is the token request incorporated into the command?

2.   Does the session request begin before or after the GET header command?

3.  I searched for other postings similar to mine but none found.  Any guidance is greatly appreciated!!!

 

EXAMPLE FROM SAMPLE CALLS DOCUMENT

$headersGET = @{}

$headersGET.Add("Authorization", "Archer session-id=" + $session_token)

$headersGET.Add("X-Http-Method-Override", "GET")

 

$headers = @{}

$headers.Add("Authorization", "Archer session-id=" + $session_token)

Thank you

cj

1 ACCEPTED SOLUTION

Accepted Solutions

SiteMinder could still be the problem for many reasons...it has not excluded the /api path from requiring authentication...or not allowing certain VERBS...etc.  Either turn off SiteMinder temporarily or have SiteMinder Team enable info logging to see if it doesn't like something you are doing.  

View solution in original post

5 REPLIES 5

Jeff
Archer Employee
Archer Employee

The 401 may indicate the /api path in IIS Manager is not set to Anonymous authentication.  

 

The headers are passed when making the REST API call.  For example, to get the Archer version, the $headersGET variable is passed to the -Headers parameter.

$api_url = $base_url + "/api/core/system/applicationinfo/version"
$results = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -ContentType "application/json" -WebSession $sess
$results.RequestedObject
$version = $results.RequestedObject.Version

Hi Jeff,

 

Thank you for the fast reply. I confirmed the required folders (API, WS, etc) are set to Anonymous authentication. Turns out all the folders under the web server are set to Anonymous. This environment runs SiteMinder but that should not interfere with API commands?

 

As a troubleshooting step I changed the Default Web Site to Windows and no change. I flipped it back to Anonymous, reset IIS and able to obtain a session token. Attempted to run the “All Applications” and now receive an error message no results

 

I will compare the IIS settings to another environment and make sure they match.

 

 

Invoke-RestMethod : The remote server returned an error: (401) Unauthorized.

At C:\Users\JohCh001\Documents\All Applications.ps1:5 char:12

+ $results = Invoke-RestMethod -Method POST -Uri $api_url -Headers $headersGET -Co ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) , WebException

+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

 

 

 

 

 

Christopher Johnson

Staples Cyber Security

T: 913.449.0782

christopher.johnson@staples.com<mailto:donald.assalone@staples.com>

SiteMinder could still be the problem for many reasons...it has not excluded the /api path from requiring authentication...or not allowing certain VERBS...etc.  Either turn off SiteMinder temporarily or have SiteMinder Team enable info logging to see if it doesn't like something you are doing.  

Good call.

 

 

 

Christopher Johnson

Staples Cyber Security

T: 913.449.0782

christopher.johnson@staples.com<mailto:donald.assalone@staples.com>

Hi,

Anything similar to retrieve the version in SOAP API?