<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JASPI 4.24+ Get JSON for current webmap state in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582401#M86467</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;&amp;nbsp;- Thanks. Really appreciate you chiming on . I will take a look at this. But I have to wonder why something so simple had to become so complicated. Haha. I looked at the V3 code in PrintTask and it looks like a bunch of&amp;nbsp; toJSON() functions were used to get the mapOptions and a _createOperationsLayers call to get the layers. All that was returned a JSON dictionary. --- I'll let you know if I can get your examples there to work. Thanks again.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Feb 2025 19:22:01 GMT</pubDate>
    <dc:creator>Arne_Gelfert</dc:creator>
    <dc:date>2025-02-05T19:22:01Z</dc:date>
    <item>
      <title>JASPI 4.24+ Get JSON for current webmap state</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1581861#M86457</link>
      <description>&lt;P&gt;I'm currently in the process of converting some JSAPI 3.x code to 4.x.&lt;/P&gt;&lt;P&gt;It used to be you could do this in 3.x&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Use 
esri/tasks/PrintParameters,
esri/tasks/PrintTask


//To get this
var params = new PrintParameters();
var webMapAsJSON = printTask._getPrintDefinition(&amp;lt;currentMap&amp;gt;, params);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;webMapAsJSON could then be sent to a custom geoprocessing service using&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var gp = new Geoprocessor("your service's url")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and manipulated to your heart's delight in Python on the back end.&lt;/P&gt;&lt;P&gt;Looks like "PrintTask" was deprecated back in 4.24... is there any way to still grab that JSON? I do not just want to send current state of web map to a layout using the new "print" module. I have all kinds of existing logic in arcpy that I&amp;nbsp; want to apply before creating a PDF.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 17:27:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1581861#M86457</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2025-02-04T17:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: JASPI 4.24+ Get JSON for current webmap state</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582378#M86465</link>
      <description>&lt;P&gt;Yes, this can be achieved in 4.x, primarily through the use of a &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-config.html#RequestInterceptor" target="_self"&gt;RequestInterceptor&lt;/A&gt;.&amp;nbsp; Basically, you'll use the interceptor to capture a print request, get the web map JSON from the request, and then cancel the request before it gets sent.&amp;nbsp; This has several pieces.&lt;/P&gt;&lt;P&gt;First, you should define a URL to a print service.&amp;nbsp; Note that in our workflow, a request will never actually get sent to it, but it's best to specify a valid one:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var printServiceURL = "https://utility.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Next, somewhere near where your application starts (e.g. where the View is created), you would set up your interceptor:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;require(["esri/config"], function(esriConfig) {
	esriConfig.request.interceptors.unshift({
		urls: printServiceURL + "/execute",
		before: function(params) {
			var error = new Error("cancel");
			error._webMapAsJSON = JSON.parse(params.requestOptions.query.Web_Map_as_JSON);
			return error;
		}
	});
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Elsewhere, you can create a function that accepts a reference to your view, and returns a Promise with the web map JSON:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;function getWebMapAsJSON(view) {
	return new Promise(function(resolve, reject) {
		require(["esri/rest/print", "esri/rest/support/PrintParameters", "esri/rest/support/PrintTemplate"], function(print, PrintParameters, PrintTemplate) {
			var printTemplate = new PrintTemplate({
				//whatever parameters desired
			});

			var printParameters = new PrintParameters({
				 //add other parameters as necessary
				template: printTemplate,
				view: view
			});

			print.execute(printServiceURL, printParameters).then(function(){}, function(e) {
				resolve(e._webMapAsJSON);
			});
		});
	});
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And then elsewhere you can call this function to get the JSON and do whatever you want with it:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;getWebMapAsJSON(view).then(function(webMapAsJSON) {
  console.info(webMapAsJSON);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 18:13:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582378#M86465</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-02-05T18:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: JASPI 4.24+ Get JSON for current webmap state</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582401#M86467</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6522"&gt;@JoelBennett&lt;/a&gt;&amp;nbsp;- Thanks. Really appreciate you chiming on . I will take a look at this. But I have to wonder why something so simple had to become so complicated. Haha. I looked at the V3 code in PrintTask and it looks like a bunch of&amp;nbsp; toJSON() functions were used to get the mapOptions and a _createOperationsLayers call to get the layers. All that was returned a JSON dictionary. --- I'll let you know if I can get your examples there to work. Thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 19:22:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582401#M86467</guid>
      <dc:creator>Arne_Gelfert</dc:creator>
      <dc:date>2025-02-05T19:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: JASPI 4.24+ Get JSON for current webmap state</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582477#M86468</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/237415"&gt;@Arne_Gelfert&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I have to wonder why something so simple had to become so complicated.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;The logic that generates the web map JSON can be seen in the esri/rest/print module, but due to the way it's encapsulated, it's impossible to get to in the same manner as 3.x.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 22:24:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/jaspi-4-24-get-json-for-current-webmap-state/m-p/1582477#M86468</guid>
      <dc:creator>JoelBennett</dc:creator>
      <dc:date>2025-02-05T22:24:10Z</dc:date>
    </item>
  </channel>
</rss>

