# When trying to update records from WebRequest - UniquenessConstraintError

**URL:** <https://community.appfarm.io/t/when-trying-to-update-records-from-webrequest-uniquenessconstrainterror/995>\
**Category:** Ask the community\
**Tags:** app-data, web-request\
**Created:** [January 18, 2024, 1:45pm UTC](https://community.appfarm.io/t/when-trying-to-update-records-from-webrequest-uniquenessconstrainterror/995 "2024-01-18T13:45:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Preben](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/preben/32/545_2.png) [@Preben](https://community.appfarm.io/u/Preben)\
**Post date:** [January 18, 2024, 1:45pm UTC](https://community.appfarm.io/t/when-trying-to-update-records-from-webrequest-uniquenessconstrainterror/995/1 "2024-01-18T13:45:45Z")

</div>

Hi,

I’m trying to update customers records in a object class “customer” using with reading all records to a runtime only object class _Customer (temp)_. The action is runs on a service triggered from the app.

Running this when the table is; empty every thing works as expected, but  
When I run it a second time to update the records we already have; I get this error: _UniquenessConstraintError: Found equal values among persisted objects_.

In the web request I have checked the boxes for update existing and add to existing. The action ends with a persist of _Customer (temp)_

Any suggestion on how to fix this or is it a bug?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/2X/a/afc16321fd887a8f17f51e65b447073d857a704b.png)

---

<div class="post-metadata">

**Author:** ![Shahitha](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/shahitha/32/66_2.png) [@Shahitha](https://community.appfarm.io/u/Shahitha)\
**Post date:** [January 24, 2024, 2:50pm UTC](https://community.appfarm.io/t/when-trying-to-update-records-from-webrequest-uniquenessconstrainterror/995/2 "2024-01-24T14:50:30Z")

</div>

Hi,

Sorry for the late response!

It seems as though this occurs because of the uniqueness requirement on the mapping property, which in this case is (assuming) refNo. Create does not match Appfarm-ID on existing objects to external ID’s. This leads to Create assuming that these are new objects, which will result in the following Persist to fail as this will collide with the uniqueness requirement.

A suggestion is to carry out this mapping in the result parser instead, which will avoid the generation of new objects.

Let us know if this helps!

---

<div class="post-metadata">

**Author:** ![kristian](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/kristian/32/58_2.png) [@kristian](https://community.appfarm.io/u/kristian)\
**Post date:** [January 24, 2024, 3:15pm UTC](https://community.appfarm.io/t/when-trying-to-update-records-from-webrequest-uniquenessconstrainterror/995/3 "2024-01-24T15:15:32Z")

</div>

Hi!

Just a small question: Does that “Customer (temp)” datasource contain all existing customers before that web request is performed? It must do so in order for the “Mapping property” feature to work: That feature should look for a customer with that refNo inside that datasource (and update if it exists, and create it if not). Otherwise, a new customer with that refNo will be created into that runtime datasource, and the uniquenessconstraint will be encounter when persisting.
