- URL:https://<diagram-url>/applyLayout
 - Version Introduced: 10.6
 
Description
The applyLayout operation is performed on a Diagram resource. The result of this operation is a Diagram JSON Information object, and the moment (date) the applyLayout operation happens for a stored diagram.
It is used to apply a specific diagram algorithm on all or parts of the resource diagram content.
Dive-in:
Starting with ArcGIS Enterprise 10.7.1, the operation can be run as an asynchronous process—async=true. In this case, it uses the system UtilityNetworkTools geoprocessing service which is reserved for utility network geoprocessing tasks and has a longer default timeout setting.
License:
The active portal account must be licensed with the ArcGIS Advanced Editing user type extension to use this operation.Request Parameters
| Parameter | Details | 
|---|---|
| gdbVersion | Description: The name of the geodatabase version. Syntax: gdbVersion=<version> Example: gdbVersion=ABV1  | 
| sessionId | Description: The token (guid) used to lock the version. Syntax: sessionId=<guid> Example: sessionId=44G259DE-87B0-407D-8F2E-DCB7665DD0F0  | 
| layoutName | Required Description: The name of the algorithm layout to apply (string) Syntax: layoutName = <AngleDirectedDiagramLayout | CompressionDiagramLayout | ForceDirectedDiagramLayout | GeoPositionsDiagramLayout | GridDiagramLayout | LinearDispatchDiagramLayout | MainLineTreeDiagramLayout | MainRingDiagramLayout | PartialOverlappingEdgesDiagramLayout | RadialTreeDiagramLayout | RelativeMainlineDiagramLayout | ReshapeEdgesDiagramLayout | RotateTreeDiagramLayout | SeparateOverlappingEdgesDiagramLayout | SmartTreeDiagramLayout | SpatialDispatchDiagramLayout > Example: layoutName = ForceDirectedDiagramLayout  | 
| layoutParams | Description: The algorithm layout parameters property set. There is a specific property set JSON object for each diagram layout parameters Syntax:  Example:  Sample of parameter property set when layoutName = ForceDirectedDiagramLayout  | 
| junctionObjectIDs | Description: For the case you want the layout algorithm to apply to a diagram part, a list of junction ObjectIDs (long) that will be processed: Syntax: junctionObjectIDs=[<DiagJctOid1>, …, <DiagJctOidN] Example: junctionObjectIDs=[1,2,3,4,5]  | 
| containerObjectIDs | Description: For the case you want the layout algorithm to apply to a diagram part, a list of container ObjectIDs (long) that will be processed: Syntax: containerObjectIDs=[<DiagConOid1>, …, <DiagConOidN] Example: containerObjectIDs=[1]  | 
| edgeObjectIDs | Description: For the case you want the layout algorithm to apply to a diagram part, a list of edge ObjectIDs (long) that will be processed: Syntax: edgeObjectIDs=[<DiagEdgOid1>, …, <DiagEdgOidN] Example: edgeObjectIDs=[1,2,3]  | 
| async | Added in 10.7.1 Description: Specifies whether the layout algorithm will run synchronously or asynchronously (Boolean). 
 Syntax: async=<true | false> Example: async=true  | 
| f | Description: The response format. The default response format is html. Values: <html | json>  | 
Example Usage
Applying the SmartTree layout algorithm with its default parameters on the entire DiagramTest2 diagram resource content; this diagram being stored in version ABV1; that is:
- URL: https://myserver.esri.com/server/rest/services/Naperville/NetworkDiagramServer/diagrams/DiagramTest2/applyLayout
 - Parameters: 
gdbVersion=ABV1 sessionId= layoutName=SmartTreeDiagramLayout layoutParams= junctionObjectIDs= containerObjectIDs= edgeObjectIDs= async= f=pjson - Sent URL (GET): https://myserver.esri.com/server/rest/services/Naperville/NetworkDiagramServer/diagrams/DiagramTest2/applyLayout?gdbVersion=ABV1&sessionId=&layoutName=SmartTreeDiagramLayout&layoutParams=&junctionObjectIDs=&containerObjectIDs=&edgeObjectIDs=&async=&f=pjson
 
JSON Response Syntax
A JSON object composed of a Diagram JSON Information object and a moment: {"diagramInfo": Diagram JSON Information, "moment": <moment>}
Note:
The moment is only returned for a stored diagram.
JSON Response Example
Sample response when synchronously applying a layout{
 "diagramInfo": {
  "tag": "",
  "isStored": true,
  "canStore": false,
  "canExtend": true,
  "isSystem": false,
  "creator": "acb7352",
  "creationDate": 1505145950000,
  "lastUpdateBy": "acb7352",
  "lastUpdateDate": 1505215730000,
  "containerMargin": 0.5,
  "junctionCount": 10,
  "edgeCount": 12,
  "containerCount": 0,
  "aggregationCount": 0,
  "isHistorical": false,
  "access": "esriDiagramPublicAccess",
  "diagramExtent": {
   "xmin": 6807604.6431991458,
   "ymin": 1848131.8394459635,
   "xmax": 6807794.5801552236,
   "ymax": 1848226.8080880493,
   "spatialReference": {
    "wkid": 3498,
    "latestWkid": 3498
   }
  },
  "networkExtent": {
   "xmin": 6807604.6431991458,
   "ymin": 1847967.7367558032,
   "xmax": 6808661.8976463079,
   "ymax": 1848650.1848659664,
   "spatialReference": {
    "wkid": 3498,
    "latestWkid": 3498
   }
  },
  "name": "DiagramTest2",
  "id": "{856490C7-ED84-44FE-8EC8-5DA4B39365C0}",
  "template": "Basic"
 },
 "moment": 1505217369240
}
Sample response when asynchronously applying a layout; that is with async=true{
 "statusUrl": "https://myserver.esri.com/server/rest/services/Naperville/UtilityNetworkServer/jobs/j03f449a0ece143f1bfc6cc676e3c4cca"
}