English

How To: Obtain a JSON string for use in the ConvertWebMapToMapDocument tool

Summary

The first parameter of the ArcPy function ConvertWebMapToMapDocument requires a JSON string defining the web map. The ArcGIS Web APIs (JavaScript, Flex, and Silverlight) allow developers to obtain this JSON string from a web application. Another way to obtain the string, using the Fiddler web debugging tool, is described in this article.

Procedure

  1. Log in to ArcGIS.com. Open the applicable web map in the map viewer.
  2. Run the Fiddler tool, and reset the option to capture traffic:

    a. From the File menu, un-check Capture Traffic.
    b. Clear any existing lines by clicking Edit > Remove > All Sessions.
    c. Enable the option to Capture Traffic again.
  3. In the map viewer, click the Print button.
  4. In Fiddler, wait for the lines related to the Print operation to be displayed in the tool dialog, then disable traffic capture and click the Inspectors tab.
    [O-Image]
  5. In the dialog window there are several lines of traffic shown. Look for the line with the following parameters:

    • In the Host column:

    Host = utility.arcgisonline.com

    • In the URL column:

    URL = /arcgis/rest/services/Utilities/PrintingTools/...

  6. Highlight the indicated record in the dialog window, and click the WebForms sub-tab under the Inspectors tab.
    [O-Image]
  7. a. View the Body section in the Inspectors/Webforms tab.
    b. In the Body section, locate the following item:
    Name = Web_Map_as_JSON

    b. Click in the Value section for that item to highlight the value.
    [O-Image]

    c. Right-click, click Copy, and paste into a text editor or Python editor capable of holding a very large string.
    [O-Image]
  8. a. When the JSON string has been pasted into a Python script, put single-quotation marks around the entire string, and assign the string to a local variable.
    [O-Image]

    b. If desired, split the string for readability, and format it according to Python syntax rules for splitting strings across multiple lines.
    [O-Image]
  9. Use the local variable as the first parameter to the ConvertWebMapToMapDocument function.
    [O-Image]

Related Information