extract_changes returns empty updates

610
4
Jump to solution
12-09-2022 08:01 AM
mikAMD
by
Occasional Contributor III

I'm testing out the extract changes endpoint and I finally got it to work, but no matter what I do, the request returns always empty "updates".

I have tried editing a couple of features, either the shape or the table information, in map viewer. Then I save it. Then I make the call again, and the information is updated in "adds" object, but nothing in "updates". The return_updates parameter is set to True.

Do I need to change the serverGen or something else? I don't get it.

 

 

 

gis = GIS("URL", username, password)
item = gis.content.get("ID")
flc=FeatureLayerCollection(item.url, gis)
sg = flc.properties.changeTrackingInfo.layerServerGens[0].serverGen
req = flc.extract_changes(
    layers=[1],
    servergen=[{"id": 1, "serverGen": sg}],
    queries={1:{"where":"FID=1981"}},
    # return_ids_only=True,
    return_inserts=True,
    return_updates=True,
    data_format="json"
)
print(req)

# {'layerServerGens': 
#[{'id': 1, 'serverGen': 914376}], 'transportType': 'esriTransportTypeUrl', 'responseType': 'esriDataChangesResponseTypeEdits', 
#'edits':[{'id': 1, 'features': 
#{'adds': [{
#'geometry': {'paths': [[[-73.6592894210589, 45.505982917298], [-73.6583249229399, 45.5044803958229], [-73.6594751091767, 45.5029865662784], [-73.6604843118765, 45.5044454814924]]]}, 
#'attributes': {'FID': 1981, 'GlobalID': 'E096B38F-B18E-4322-BB4D-DBA25EE65BA0', 'id': 99999, 'terrain': '1', 'niveau_ms': 1, 'source': 'abc', 'CreationDate': 1670533735636, 'Creator': 'ME', 'EditDate': 1670601353246, 'Editor': 'ME', 'notes': 'updated feature', 'bb': 0}
#}], 
#'updates': [], 
#'deleteIds': []
#}}]}

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
mikAMD
by
Occasional Contributor III

Finally managed to put some time on this.

I don't know what I was doing wrong previously, possibly filtering (with "queries") on the wrong layer (1 instead of 0).

Anyway everything seems ok on my end.

gis = GIS("https://amd-montreal.maps.arcgis.com/", username, password)
serviceId = "abc"
serviceItem = gis.content.get(serviceId)
flc = FeatureLayerCollection(serviceItem.url, gis)

sg = flc.properties.changeTrackingInfo.layerServerGens[0].serverGen

req = flc.extract_changes(
    layers=[0], # layer
    servergen=[{"id": 0, "serverGen": sg}],
    return_ids_only=True,
    return_inserts=True,
    return_updates=True,
    return_deletes=False
)

print(req)
# {'layerServerGens': [{'id': 0, 'serverGen': 1274270}], 'transportType': 'esriTransportTypeUrl', 'responseType': 'esriReplicaResponseTypeEdits', 'edits': [{'id': 0, 'objectIds': {'adds': [], 'updates': [1, 2, 4, 8], 'deletes': []}}]}

 

View solution in original post

0 Kudos
4 Replies
JohnYaist1
Esri Contributor

Hi  - Try entering the servergen parameter like this instead of as a dictionary in a list:

servergen = sg

 

0 Kudos
mikAMD
by
Occasional Contributor III

Thanks for your suggestion. Will be trying it out as soon as possible and update/accept as solution if that is the case.
Thank you!

0 Kudos
jkersting
New Contributor II

After some testing having the same issue where Updates always returns empty [], I realized that updates are currently showing together with the inserts.

Try doing this: returnInserts and ReturnDeletes = false and returnupdates = true.

 

The updated features should show in the Inserts list.

Maybe this is a bug.

 

Needs more investigation.  

0 Kudos
mikAMD
by
Occasional Contributor III

Finally managed to put some time on this.

I don't know what I was doing wrong previously, possibly filtering (with "queries") on the wrong layer (1 instead of 0).

Anyway everything seems ok on my end.

gis = GIS("https://amd-montreal.maps.arcgis.com/", username, password)
serviceId = "abc"
serviceItem = gis.content.get(serviceId)
flc = FeatureLayerCollection(serviceItem.url, gis)

sg = flc.properties.changeTrackingInfo.layerServerGens[0].serverGen

req = flc.extract_changes(
    layers=[0], # layer
    servergen=[{"id": 0, "serverGen": sg}],
    return_ids_only=True,
    return_inserts=True,
    return_updates=True,
    return_deletes=False
)

print(req)
# {'layerServerGens': [{'id': 0, 'serverGen': 1274270}], 'transportType': 'esriTransportTypeUrl', 'responseType': 'esriReplicaResponseTypeEdits', 'edits': [{'id': 0, 'objectIds': {'adds': [], 'updates': [1, 2, 4, 8], 'deletes': []}}]}

 

0 Kudos