1

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" }

4
  • Its unlikely its your code if you're submitting successfully. The problem will be the parameters you're passing to the service itself. This particular tool is tricky to call directly. Generally the caching tools are called from the associated tool inside ArcMap or another client and these 2 pieces talk to each other really well. Perhaps if you use Fiddler to spy on the communication between arcmap's tool and the cache service tool, you'll see a difference in parameter values and can update your parameters to match
    – KHibma
    Commented Aug 5, 2016 at 15:13
  • That's strange ... on the UI there's a checkbox that says "Wait for job completion (optional)". Yet I don't see any arcpy parameter for that. This tool differs from others - you can get back a message saying "completed" when in fact the job is still running (i.e. tiles are still being generated). Commented Aug 5, 2016 at 16:20
  • You might also look into ReportCacheStatus Commented Aug 5, 2016 at 16:29
  • Log into Server Manager on the GIS server and check the Logs tab there. It will usually contain more helpful information about the issue than what gets returned by the tool.
    – Mintx
    Commented Aug 5, 2016 at 16:41

2 Answers 2

1

I took the advice of KHibma -make an answer- and looked at the communication between ArcMap and ArcGIS Server using Fiddler. As expected, the "service_url" was incorrect.

I was using the rest service URL (which is incorrect): http://arcgistest.domain.net:6080/arcgis/rest/services/TestServices/TestPoints/MapServer

Instead, ArcMap sends the following text in the "service_url" parameter (which is correct): "TestServices/TestPoints:MapServer"

where "TestServices" is the Service directory and "TestPoints" is the Map Service.

The following code successfully re-created the map cache.

private static void TryMapCache(string[] args, string token)
    {
        args = new string[7];
        string url = "http://arcgistest.domain.net:6080/arcgis/rest/services/System/CachingControllers/GPServer/";

        args[0] = "Manage Map Cache Tiles/SubmitJob?";
        args[1] = "service_url=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)
        {
            //parse the response body
            string responseData = theResponse.Content.ReadAsStringAsync().Result;
            Console.WriteLine(responseData);
            Console.ReadKey();
        }
    }
0

Here is the code for Manage Map Cache using ArcGIS Server 10.4 REST API using Python.

import requests

taskUrl = " http://arcgistest.domain.net:6080/arcgis/rest/services/TestServices/TestPoints/MapServer"

manageMapCacheUrl = taskUrl + "/Manage Map Cache Tiles/SubmitJob?"

payload = {
    'service_url': "TestServices/TestPoints:MapServer",
    'levels': "1155581.108577;577790.55428",
    'thread_count': 6,
    'update_mode': "RECREATE_ALL_TILES",
    'f':'pjson'
}

headers = {'Authorization': 'Bearer ' + token }
submitResponse = requests.request(
        "POST", manageMapCacheUrl, headers=headers, data=payload) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.