Select to view content in your preferred language

An item with the same key has already been added.

229
2
07-07-2025 01:57 PM
ClayMeredith
New Contributor

Hi everyone,

I've got a fairly complex Survey123 form that has been build using an XLSForm and links to an existing hosted feature layer. The survey involves multiple repeats with related tables. The top layer (a point file) gives me no trouble, nor does the child related table. However, when I add in a second related table (a child of the first related table edited via a repeat within a repeat), I get a non-specific error on submission (shown below).

ClayMeredith_1-1751920763520.png

 

ClayMeredith_2-1751920798545.png

<10>1 2025-07-07T20:19:06Z IAE-CMeredith ArcGISSurvey123 27916 - [AppStudio@11205 category="PortalRequest" function="onFailed" filename="PortalRequest.qml" line="149"] PortalRequest: PortalRequest failed url: https://services8.arcgis.com/Qitq5PCIrDNxTvXl/arcgis/rest/services/SWSP_EDC_v8/FeatureServer/applyEd... error: {
"code": 400,
"details": [
"'edits' parameter is invalid",
"An item with the same key has already been added.",
"Unable to apply edits."
],
"message": ""
}
<15>1 2025-07-07T20:19:06Z IAE-CMeredith ArcGISSurvey123 27916 - [AppStudio@11205 category="XFormFeatureService" function="onFailed" filename="XFormFeatureService.qml" line="810"] XFormFeatureService: applyEdits error: {
"error": {
"code": 400,
"details": [
"'edits' parameter is invalid",
"An item with the same key has already been added.",
"Unable to apply edits."
],
"message": ""
}
}
<15>1 2025-07-07T20:19:06Z IAE-CMeredith ArcGISSurvey123 27916 - [AppStudio@11205 category="qml" function="onFailed" filename="SurveyFolderPageOutbox.qml" line="378"] qml: Feature service error: {
"code": 400,
"details": [
"'edits' parameter is invalid",
"An item with the same key has already been added.",
"Unable to apply edits."
],
"message": ""
}

I've attempted to identify the specific line which causes the error by removing individual questions from the repeat which is causing the issue with no success. The error persists even when the form is stripped down to a single optional text field (shown below).

ClayMeredith_4-1751921375071.png

Recreating the relationship class has not solved the issue (parameters shown below).

ClayMeredith_3-1751921203787.png

At this point I'm not sure where to go with troubleshooting.

Any help would be greatly appreciated.

Thanks!

 

 

0 Kudos
2 Replies
Leena_Abdulqader
Frequent Contributor

Hey @ClayMeredith, hope you are well. You're definitely deep into a tricky Survey123 + nested repeat + related table issue haha. The error message: "An item with the same key has already been added." combined with:"'edits' parameter is invalid"means that Survey123 is trying to send multiple edits with duplicate keys (likely duplicate GlobalIDs or OBJECTIDs) to the applyEdits endpoint of your feature service.

This is especially likely in these situations:

  • You’re using nested repeats AND submitting in offline mode or from the outbox
  • Using an existing feature layer with prepopulated GlobalIDs
  • The nested repeat is incorrectly referencing the parent/global ID

In your XLSform: Are you using a calculation for the GlobalID in any of the tables? Is repeat_count used anywhere (even commented out)?

If your XLSForm manually references the GlobalID field in any way, try to remove it.

I would also recommend testing with a fresh Feature Layer created from similar survey questions. See if the submission works with the same input.

0 Kudos
BethanyCrenshaw1
Regular Contributor

Thank you for posting this.  Did you have any luck solving this?  I have the same issue: 

{"error":{"code":400,"message":"","details":["'edits' parameter is invalid","An item with the same key has already been added.","Unable to apply edits."]}}   My Survey123 form is trying to write to a database with many relates. 

 Thank you @Leena_Abdulqader for the suggestions, I looked at those, but I've not yet found the solution.

0 Kudos