Important Update: Community URLs redirect issues are partially resolved. Learn More. .

cancel
Showing results for 
Search instead for 
Did you mean: 

Error while calling contentapi

grv.mishra
Collaborator III

I am trying to call contentapi using below code but I am getting error, I can access content api from browser and getting all the endpoint. Am I doing something wrong.

 

Code -

$SessionToken = "session token of account with admin access"
$Server = "https://myarcherserver"
$Uri = "contentapi"
$Headers = @{"accept" = "application/json"; "content-type" = "application/json"; "Authorization" = ("Archer session-id=`"" + $SessionToken + "`""); "X-Http-Method-Override" = $Method.GET }
$Response = Invoke-RestMethod -Method $Method.POST -Headers $Headers -Uri ($Server+$Uri) -body (convertto-json $Body)
$Response

 

 

Error I am getting -

 

Invoke-RestMethod :
401 - Unauthorized: Access is denied due to invalid credentials.
Server Error

401 - Unauthorized: Access is denied due to invalid credentials.
You do not have permission to view this directory or page using the credentials that you supplied.

1 ACCEPTED SOLUTION

Accepted Solutions

Ilya_Khen
Champion III

Are you pointing to the contentapi node in your url? because example is not clear on that.

 

Also, I am not sure if you need to use single quotes (`) on the session-id in your header for authorization.

View solution in original post

11 REPLIES 11

Ilya_Khen
Champion III

Are you pointing to the contentapi node in your url? because example is not clear on that.

 

Also, I am not sure if you need to use single quotes (`) on the session-id in your header for authorization.

grv.mishra
Collaborator III

Thnx, I removed quote and it worked.

Anytime

Strangely contetapi stopped working and I see below error while accessing it via browser. I have anonymous authentication enabled and Windows Authentication disabled. It was working till yday but stopped working now what could be the issue.

pastedImage_1.png

Check if account got locked somehow.

Account is active and has sysadmin access, not only my script has stopped working also I cant access content api via browser.

Are u using non windows integrated SSO? Maybe SiteMinder or similar?

 

Maybe these API nodes are shielded by SSO then?

We are using windows sso.

When I enable windows auth it works but prompts work creds. I dont want that. But it was working with anonymous auth earlier.