FRAMES | NO FRAMES Description | Parameters | Examples | Response
Synchronize Replica - Feature Service (Operation)
URL http://<featureservice-url>/synchronizeReplica(POST only)
Parent Resource Feature Service
Required Capability Create,Update,Delete

Description

Note: This operation is not supported in 10.1 Beta 1

The synchronize replica operation is performed on a feature service resource. This operation synchronizes changes between the feature service and a client based on the replicaID provided by the client.

The client obtains the replicaID by first calling the createReplica operation.

Synchronize applies the client's data changes by importing them into the server's Geodatabase. It then exports the changes from the server Geodatabase that have taken place since last time the client got the data from the Server.

The response for this operation includes the replicaID, a new server generation number and response type.

You can provide arguments to the synchronizeReplica operation as query parameters defined in the parameters table below.

Parameters

Parameter Details
f Description: The response format. The default response format is html.

Values: html | json

replicaID Description: The ID of the replica you wish to synchronize. This is a required parameter.

Syntax:
replicaID=<replicaID>
Example:
replicaID={90F07F7B-991C-4818-B7CA-97B2BF4F7CAA}
replicaServerGen Description: The replicaServerGen is a generation number that allows the server to keep track of what changes have already been synchronized. A new replicaServerGen is sent with the response to the synchronizeReplica operation. Clients should persist this value and use it with the next call to synchronizeReplica.

Syntax:
replicaServerGen=<replicaServerGen>
	
Example:
replicaServerGen=2
	
transportType Description: The tranportType represents the response format. If the transportType is esriTransportTypeUrl, the JSON response is contained in a file and the URL link to the file is returned.

Values: esriTransportTypeUrl | esriTransportTypeEmbedded

closeReplica Description: If true, the replica will be dropped when the synchronize completes. This is the same as calling synchronize and then calling unregisterReplica. Otherwise the replica can continue to be synchronized. The default is false.

Values: true | false
returnIdsForAdds Description: If true, the objectids and globalids of features added during the synchronize will be returned to the client. Otherwise the ids are not returned. The default is false.

Values: true | false
edits Description: The edits the client wishes to apply to the service.

The edits are described using an array where an element in the array includes:
  • The layer or table ID.
  • The feature or row edits to apply listed as inserts, updates and delete.
  • The attachments to apply listed as inserts, updates and delete.

For features, adds and updates are specified as feature objects which include geometry and attributes.

Deletes can be specified using globalids for features and attachments.

For attachments, updates and deletes are specified using the following set of properties for each attachment. If embedding the attachment set the data otherwise set the url property. All of the properties are required:
  • globalid: The globalid of the attachment that is to be added or updated.
  • parentGlobalid: The globalid of the feature associated with the attachment.
  • contentType: Describes the file type of the attachment (e.g. image/jpeg)
  • name: The file name (e.g. hydrant.jpg)
  • data: The base 64 encoded data if embedding the data.
  • url: the location from which the service will upload the attachment file (e.g. http://machinename/arcgisuploads/Hydrant.jpg)


Syntax:
"edits":[
	{ 
	"id" : <layerId1>,
	"features" : {
		"adds" : [<feature1>, <feature2>],
		"updates" : [<feature1>, <feature2>],
		"deleteIds" : [<globalID1>, <globalID2>]},
	"attachments" : {
		"adds" : [<attachment1>, <attachment2>],
		"updates" : [<attachment1>, <attachment2>],
		"deleteIds" : [<globalID1>, <globalID2>]},
	},
	{ 
	"id" : <layerId2>,
	"features" : {
		"adds" : [<feature1>, <feature2>],
		"updates" : [<feature1>, <feature2>],
		"deleteIds" : [<globalID1>, <globalID2>]},
	"attachments" : {
		"adds" : [<attachment1>, <attachment2>],
		"updates" : [<attachment1>, <attachment2>],
		"deleteIds" : [<globalID1>, <globalID2>]},
	}
]


Example:

"edits": [
    {"id" : 1,
    "features" : { 
     "adds" : [ 
    {
      "geometry" : 
	  {
        "x" : -178.24479999999991,
        "y" : 50.012500000000045
      },
      "attributes" : 
	  {
	    "globalID" :"{8991B712-D26F-407d-9116-06B0CEF0F010}",
        "datetime" : 1272210710000,
        "depth" : 31.100000000000001,
        "eqid" : "2010vma5",
        "latitude" : 50.012500000000003,
        "longitude" : -178.2448,
        "magnitude" : 4.7999999999999998,
        "numstations" : 112,
        "region" : "Andreanof Islands, Aleutian Islands, Alaska",
        "source" : "us",
        "version" : "Q"
      }
    }
   ],
     "updates" : [
    {
      "geometry" : 
	  {
        "x" : -178.24479999999991,
        "y" : 50.012500000000045
      },
      "attributes" : 
	  {
	"globalID" :"{59229CA9-4DF2-4d4d-B6A3-5504D08C1F7A}",
        "datetime" : 1272210710000,
        "depth" : 31.100000000000001,
        "eqid" : "2010vma5",
        "latitude" : 50.012500000000003,
        "longitude" : -178.2448,
        "magnitude" : 4.7999999999999998,
        "numstations" : 112,
        "region" : "Andreanof Islands, Aleutian Islands, Alaska",
        "source" : "us",
        "version" : "Q"
      }
    }    
	],
    deleteIds : [
				"{AAB7CD51-AA70-4a99-B3F6-E71E5D356758}",
				"{47EC4FF1-C748-456b-B9DF-AC9F32A9EDBC}"
     ]
    },  
    "atttachments" : { 
     "adds" : [ 
	{
	"globalId" : "{6CD00D29-F37E-4e77-9C74-361B719A42DB}",
	"parentGlobalId":"{8991B712-D26F-407d-9116-06B0CEF0F010}",// feature's id
	"contentType:"image/pjpeg"
	"name:"Hydrant101.jpg"
	"url:"http://machinename/arcgisuploads/Hydrant101.jpg"
	}
     ],
     "updates" : [ 
	{
	"globalId" : "{934D1E05-BC1D-4d45-961A-4892C8C65135}",
	"contentType:"image/pjpeg"
	"name:"Hydrant202.jpg"
	"url:"http://machinename/arcgisuploads/Hydrant202.jpg"
	}
     ],
    "deleteIds" : [
				"{3048BF42-425B-48f4-8C2B-E3797EF9C64C}",
				"{6E562021-B13F-4915-9218-3D93B483F8DA}"
     ]
    } //end of attachments
  }, //end of layer 1 data
  {
    "id" :5,
    "features" : {
     "adds" : [
    {
      "geometry" : {
        "x" : 242.24556961400003,
        "y" : 34.260686249000059
      },
      "attributes" : {
	"globalId" : "{50EBEDE7-8C9B-4bb5-95B5-1C78B8A90D76}",
        "type" : 0,
        "description" : "California Fire Department"
      }
    },
    {
      "geometry" : {
        "x" : 242.44111296000005,
        "y" : 34.266616200000044
      },
      "attributes" : {
	"globalId" : "{022265BD-5153-4b59-B62D-27D3C051528D}",
        "type" : 6,
        "description" : "San Gorgonio mountain"
      }
    }
  ],
     "updates" : [
    {
      "geometry" : {
        "x" : 242.21472194300009,
        "y" : 34.33949752500007
      },
      "attributes" : {
	"globalId" : "{14CAFE0D-A9E0-4467-9905-06DC31E9C76B}",
        "type" : 1,
        "description" : "100 bed shelter."
      }
    },
    {
      "geometry" : {
        "x" : 242.17137744600006,
        "y" : 34.259303879000072
      },
      "attributes" : {
	"globalId" : "{89682769-E960-4a07-BC57-19634AAD7638}",
        "type" : 5,
        "description" : "gutted ranger station"
      }
    }
  ],
    "deleteIds" : [ 
				"{0AA0E51C-0B3D-45b8-92EE-7E5E4329BF03}",
				"{DE708C1C-ACAF-4a75-8815-1BE35B06CC38}"
     ]
    } //end of features
  } //end of layer 2 data
] //end of layers
returnAttachmentDatabyURL Description: If true, a reference to a URL will be provided for each attachment returned from synchronizeReplica. Otherwise attachments are embedded in the response. The default is true.

Note, applies only if attachments are included in the replica.

Values: true | false

Example Usage

Example 1:Synchronize data changes and attachments using the synchronize replica opertaion on the feature service resource.

http://gm8:6080/arcgis/rest/services/samplepoints/FeatureServer/synchronizeReplica

JSON Response Syntax

{ // synchronizeReplica response
  "replicaID"   : "<replicaID>", // unique value that identifies the replica
  "replicaServerGen: <replicaServerGen>, // read only value by clients
   "responseType": 
"<esriReplicaResponseTypeEdits> |  // Returns just the changes since the last synchronize.
 <esriReplicaResponseTypeReplcementData>"  // Returns all data in replica. Existing cache should be replaced with this data. 

  "edits": [	
  {  // layer 1 edits
    "id" : <layerId1>,
    "features" : { //features will include geometry for feature layers only
     "adds" : [ 
       <feature1>, <feature2> 
     ],
     "updates" : [
       <feature1>, <feature2>
    ],
    "deleteIds" : [ "", ""]
    }, //end of layer 1 features' edits
    "atttachments" : { 
     "adds" : [ 
       <attachment1>, <attachment2> 
     ],
     "updates" : [ 
       <attachment1>, <attachment2> 
     ],
    "deleteIds" : [ "", ""]
    } //end of layer 1 attachments' edits
  }, // end of layer 1 edits
   { // layer 2 edits
    "id" : <layerId2>,
    "features" : { //features will include geometry for feature layers only
     "adds" : [ 
       <feature1>, <feature2> 
     ],
     "updates" : [
       <feature1>, <feature2>
    ],
    "deleteIds" : [ "", ""]
    }, //end of layer 2 features' edits
    "atttachments" : { 
     "adds" : [ 
       <attachment1>, <attachment2> 
     ],
     "updates" : [ 
       <attachment1>, <attachment2> 
     ],
    "deleteIds" : [ "", ""]
    } //end of layer 2 attachments edits
   }  // end of layer 2 edits
  ] //end of edits

 idsForAppliedAdds: [
 {     // ids for layer 1
       id: <layerIds1>,
       idsForAddedFeatures: [
       {
	 globalId:"<globalId1>," // globalID of a feature
	 objectId:<objectId1> // The feature's objectId in server Geodatabase
	},
        {
	  globalId:"<globalId2>",
	  objectId:<objectId2>
        }
      ], // end of idsForAddedFeatures
      idsForAddedAttachments: [
        {
	 globalId:"<globalId1>", // An added attachment's globalID
         attachmentId:<objectId1> // The attachmentId in the server
	},
        {
	  globalId:"<globalId2>",
	  attachmentId:<objectId2>
        }
       ] // end of idsForAddedAttachments
     }, // end of ids for layer 1
     {  // ids for layer 2
       id: <layerIds2>,
       idsForAddedFeatures: [ {
	 globalId:"<globalId1>",
	 objectId:<objectId1>
 	},  
	{
		globalId:"<globalId2>",
	  	objectId:<objectId2>
	} 
	], // end of idsForAddedFeatures
      idsForAddedAttachments: [ {
	 globalId:"<globalId1>",
         attachmentId:<objectId1>
	 },
        {
	  globalId:"<globalId2>",
	  attachmentId:<objectId2>
        }
       ] // end of idsForAddedAttachments
     } // end of ids for layer 2
 ] //end of idsForAppliedAdds

}//end of synchronizeReplica response 

JSON Response Example

{
  "replicaID"   : "{90F07F7B-991C-4818-B7CA-97B2BF4F7CAA}",
  "replicaServerGen: 1,
  "responseType": "esriReplicaResponseTypeEdits"
	
  "edits": [	
  {  // layer 1 edits
    "id" : 0,
    "features" : {
     "adds" : [ 
    {
      "geometry" : {
        "x" : -183.24479999999991,
        "y" : 49.012500000000045
      },
      "attributes" : {
	"objectID":5000,
	"globalID" :"{93BADD75-B2B7-497a-99F0-6E89B09C9C8E}",	
        "latitude" : 50.012500000000003,
        "longitude" : -178.2448,
        "magnitude" : 4.7999999999999998,
        "numstations" : 112,
        "region" : "Hawaii",
        "source" : "us",
        "version" : "Q"
      }
    },
    {
      "geometry" : {
        "x" : -153.24479999999991,
        "y" : 47.012500000000045
      },
      "attributes" : {
	"objectID":5001,
	"globalID" :"{9B395A2F-2A97-443f-8A32-0EDCC031226B}",	
        "latitude" : 50.012500000000003,
        "longitude" : -178.2448,
        "magnitude" : 4.7999999999999998,
        "numstations" : 115,
        "region" : "Inland Empire",
        "source" : "us",
        "version" : "Q"
      }
    }     ],
     "updates" : [   
      {
        "geometry" : {
        "x" : -153.24479999999991,
        "y" : 47.012500000000045
        },
        {
	 "objectID":3000,
	 "globalID" :"{FE326A5F-987E-4e2e-860D-412B48048C8A}",	
         "latitude" : 51.012500000000003,
         "longitude" : -170.2448,
         "magnitude" : 4.7999999999999998,
         "numstations" : 112,
         "region" : "Hawaii",
         "source" : "us",
         "version" : "P"
        }
      }, 
      {
        "geometry" : {
        "x" : -53.24479999999991,
        "y" : 46.012500000000045
        },
        {
	 "objectID":3001,
	 "globalID" :"{96D0B1BB-9B18-4e9f-B3FE-D1EDE124C690}",	
         "latitude" : 50.012500000000003,
         "longitude" : -1720.2448,
         "magnitude" : 4.7999999999999998,
         "numstations" : 113,
         "region" : "Hawaii",
         "source" : "us",
         "version" : "P"
        }
      }    ],
    deleteIds : [ 
        "{CDEBA241-9B2D-446f-8929-3ADA46562481}",
				"{D447148D-4FCC-4c71-826F-D64E76F9ED79}"
		]
    }, //end of layer 1 features' edits
    "atttachments" : { 
     "adds" : [ 
	{
	"attachmentId": 9000,
	"globalId" : "{C9F8AB95-BA0B-4f60-BF3D-8D06388A641F}",
	"paretnGlobalId":"{79347B9B-105F-427e-9182-308F00A0BB19}",
	"parentId": 7000,
	"contentType:"image/png"
	"name:"Hydrant107.png"
	"url:"http://machinename/ArcGIS/rest/services/Incidents/FeatureServer/7/70000/attachments/6430"
    }, 
  {
	"attachmentId": 9001,
	"globalId" : "{55058442-52A0-49ed-818D-6F87D52A919E}",
	"paretnGlobalId":"{FA21DB5B-E398-4bc3-AC8A-A2B39E4E4CC9}",
	"parentId": 7001,
	"contentType:"image/png"
	"name:"Hydrant108.png"
	"url:"http://machinename/ArcGIS/rest/services/Incidents/FeatureServer/7/7001/attachments/6430"
    }     ],
     "updates" : [ 
      {
	"attachmentId": 9002,
	"globalId" : "{562667BF-BBCA-4ca0-8B29-51FB06F4E2B7}",
	"contentType:"image/png"
	"name:"Hydrant109.png"
	"url:"http://machinename/ArcGIS/rest/services/Incidents/FeatureServer/7/7002/attachments/6430"
     }, 
     {
	"attachmentId": 9003,
	"globalId" : "{28F5B495-1F55-4d6a-9257-FA67804F25A0}",
	"contentType:"image/png"
	"name:"Hydrant110.png"
	"url:"http://machinename/ArcGIS/rest/services/Incidents/FeatureServer/7/7003/attachments/6430"
    }     ],
    "deleteIds" : [
				"{B539AADB-1FAF-4e7d-8168-1FBBC0B87C83}",
				"{04C9B94E-BA40-43db-BC8E-8A2DFE0CE116}"
	]
    } //end of layer 1 attachments' edits
  } // end of layer 1 edits
  ] //end of edits

 idsForAppliedAdds: [
 {       id: 1,
       idsForAddedFeatures: [
       {
	 globalId:"{8991B712-D26F-407d-9116-06B0CEF0F010}",
	 objectId: 101
	},
        {
	  globalId:"{5E7E50DB-AA1F-404f-91AE-16AB1763C96D}",
	  objectId:1002
        }
      ], // end of idsForAddedFeatures
      idsForAddedAttachments: [
        {
	 globalId:"{6CD00D29-F37E-4e77-9C74-361B719A42DB}",
         attachmentId:500
	},
        {
	  globalId:"{5470869C-E214-4515-8301-74ECD745F1DE}",
	  attachmentId:501
        }
       ] // end of idsForAddedAttachments
     },
     {
       id: 5,
       idsForAddedFeatures: [ 
	{
	 globalId:"{022265BD-5153-4b59-B62D-27D3C051528D}",
	 objectId:400
	}
	],
       idsForAddedAttachments: [ 
	{
	 globalId:"{70C827C0-C4FF-4377-94B3-5C6E6DBA0409}",
         attachmentId:600
	},
        {
	  globalId: "{BB9CD04D-79F4-42da-BD07-BDF16693B6B2}",
	  attachmentId:601
        }
       ]
     }
 ] //end of idsForAppliedAdds
}//end of synchronizeReplica response