I am trying to use the ArcGIS Server 10.4 REST API to manage map caches via C#.NET, System.Net.Http. I am able to access and utilize the REST API with this technology, so I know it can work. But this specific attempt fails every time with the following error:
Error executing tool. Manage Map Cache Tiles Job ID: j89eeb39daaba427891dcc5cefe90a0d0 : ERROR 001428: Failed to retrieve configuration for service http://arcgistest.domain.net:6080/arcgis/rest/services/TestServices/TestPoints/MapServer/. Failed to execute (Manage Map Cache Tiles).
As you can see by the error message I am able to submit a job to the proper service (that is after generating a token, which is required for the System geoprocessing services). Furthermore, if I remove one of the required parameters I get a message telling me so. This helps me to know I'm on the right track.
My best guess is the "service_url" parameter is not correct but the documentation on what to supply here is not helpful and mainly for python applications which will be running on a local machine. My goal is to create a service wrapper for a non-gis developer...
private static void TryMapCache(string[] args, string token)
{
args = new string[7];
string url = "http://arcgistest.domain.net:6080/arcgis/rest/services/System/CachingTools/GPServer/";
args[0] = "Manage%20Map%20Cache%20Tiles/SubmitJob?";
args[1] = "service_url=http://arcgistest.domain.net:6080/arcgis/rest/services/TestServices/TestPoints/MapServer;
args[2] = "&levels=1155581.108577;577790.554289";
args[3] = "&thread_count=6";
args[4] = "&update_mode=RECREATE_ALL_TILES";
args[5] = "&f=pjson";
args[6] = "&token=" + token;
StringBuilder urlParameters = new StringBuilder();
urlParameters.Append(args[0].ToString());
urlParameters.Append(args[1].ToString());
urlParameters.Append(args[2].ToString());
urlParameters.Append(args[3].ToString());
urlParameters.Append(args[4].ToString());
urlParameters.Append(args[5].ToString());
urlParameters.Append(args[6].ToString());
Console.WriteLine(url + urlParameters.ToString());
HttpClient theClient = new HttpClient();
theClient.BaseAddress = new Uri(url);
//data response
HttpResponseMessage theResponse = theClient.GetAsync(urlParameters.ToString()).Result;
if (theResponse.IsSuccessStatusCode)
{
string responseData = theResponse.Content.ReadAsStringAsync().Result;
Console.WriteLine(responseData);
Console.ReadKey();
}
}
This is the output:
{ "jobId": "j8f9f5f6412ac4d688540bad252cfee3e", "jobStatus": "esriJobSubmitted" }
Logs
tab there. It will usually contain more helpful information about the issue than what gets returned by the tool.