Select to view content in your preferred language

Obtaining ArcGIS Server token programmatically

1643
2
Jump to solution
01-09-2023 10:14 AM
Arne_Gelfert
Regular Contributor

Trying to do a little more with ArcGIS Server logs. So I want access them programmatically.

Using FME to connect to my server/admin page for generating tokens:

myserver.domain:6443/arcgis/admin/generateToken

This is where I can grab a token manually in the browser. I can then plug that token as parameter in the query using FME (HTTP Caller) and - boom - I'm talking to ArcGIS Server.

But when I try to hit the above endpoint with a POST in FME (HTTP Caller) directly to get a token that way, I cannot get ArcGIS Server to send me one. All I get are errors. Other parameters I use (per instructions here) are:

client : requestip
f : json

and headers:

Content-type : application/x-www-form-urlencoded
Accept : text/plain

Putting username/password in the body, it cannot be found. If I put it in the query, I get a ""POST request should not contain username and password in the query string." Am I doing this wrong, or could this be related to BUG-000129762. it's unclear to me in the bug description if it's a Portal or AGOL issue. But since I'm on 10.9 and the bug references a 10.9.1 fix, I'm wondering.

0 Kudos
1 Solution

Accepted Solutions
JamesGough
Occasional Contributor

From the error it sounds like you are including the parameters in the query string portion of the URL. You should instead send all of the parameters in the body of the POST request.

I'm not familiar with FME so i can't tell you exactly how to do that in FME, but you need to specify application/x-www-form-urlencoded for the Content-Type and then include all of the parameters in the body instead of query string.

View solution in original post

0 Kudos
2 Replies
JamesGough
Occasional Contributor

From the error it sounds like you are including the parameters in the query string portion of the URL. You should instead send all of the parameters in the body of the POST request.

I'm not familiar with FME so i can't tell you exactly how to do that in FME, but you need to specify application/x-www-form-urlencoded for the Content-Type and then include all of the parameters in the body instead of query string.

0 Kudos
Arne_Gelfert
Regular Contributor

Sweet! Thanks, @JamesGough ! Putting all the parameters in the body was the part I was not doing.

 


@JamesGough wrote:

....you need to ....include all of the parameters in the body instead of query string.


Learned something new I should've probably already known. Have a great day!