The documentation is unclear exactly how to send the username, password, and other parameters in the REST POST.
The documentation is here : <ArcGIS REST API >
I've tried
curl -X POST https:///www.arcgis.com/sharing/rest/generateToken?username=me&password=XX&client=ip&ip=aa.bb.cc.dd
curl -X POST -d username=me -d password=XX -d client=ip -d ip=aa.bb.cc.dd https://www.arcgis.com/sharing/rest/generateToken
curl -X POST -d @ebody https://company.maps.arcgis.com/sharing/rest/generateToken
where ebody is a file containing
username=me
password=XX
client=ip
ip=aa.bb.cc.dd
and variations on all of them.
Does anyone have a working example, or explain what to use for the base url? Does it matter?
Sometimes I'll get a 404, other times I get an HTML response:
<html>
<head>
<title>ArcGIS Portal Directory</title>
<link href="https://community.esri.com/sharing/rest/files/gw.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<br/>
<div class="gwDiv">
<table class="navTable" width="100%"><tr><td class="breadcrumbs">ArcGIS Portal Directory</td></tr></table>
<tr valign="top">
<br/><br/>
<b>
<a href="http://resources.arcgis.com/en/help/arcgis-rest-api/" >API Reference</a>
</b>
</tr>
</table>
</div>
</body>
Solved! Go to Solution.
Well, the ultimate trick was providing an "f=json" parameter. I was really close.
curl -X POST -d username=me -d password=XX -d referer=www.company.com f=json https://www.arcgis.com/sharing/rest/generateToken
Which finally returned the response....
{"token" : "-DZuy32O7y40jlKNOTREALLYnorCerffLl5THECGSTy1tUO6zpReAl8nMVb1pI8ccn1lYkR-CEPsDgaSTaZF1U49aoC9B1aObUToKEn2fQJ_ZVYRf_0CSkS-2p1eTIpigoI548k7AVWAQ4x21l-0RHdQQnB1pslpXhpSE.","expires" : 1410382414882,"ssl" : true}
Well, the ultimate trick was providing an "f=json" parameter. I was really close.
curl -X POST -d username=me -d password=XX -d referer=www.company.com f=json https://www.arcgis.com/sharing/rest/generateToken
Which finally returned the response....
{"token" : "-DZuy32O7y40jlKNOTREALLYnorCerffLl5THECGSTy1tUO6zpReAl8nMVb1pI8ccn1lYkR-CEPsDgaSTaZF1U49aoC9B1aObUToKEn2fQJ_ZVYRf_0CSkS-2p1eTIpigoI548k7AVWAQ4x21l-0RHdQQnB1pslpXhpSE.","expires" : 1410382414882,"ssl" : true}
How to test an existing token with curl?
Examples:
1) Token with IP Address or IP address of this request's origin
curl.exe -v "http://xxx/arcgis/rest/services/one/one_mapservice/MapServer/export?bbox=2606311.7,1183257.7,2609357..."
2) Token with HTTP Referer:
curl.exe -v --header "referer: http:referer-url" "http://xxx/arcgis/rest/services/one/one_mapservice/MapServer/export?bbox=2606311.7,1183257.7,2609357..."
Note: With header HTTP_REFERER: Getting '498 - Invalid Token'
curl.exe -v --header "HTTP_REFERER: http:referer-url" "http://xxx/arcgis/rest/services/one/one_mapservice/MapServer/export?bbox=2606311.7,1183257.7,2609357..."