Error when modifying multiple contacts with single-valued property with null value
SOLVE
Hi!,
I have a property ‘subscription__monthly’ set to have unique values. When from Python I call the function ‘client.crm.contacts.batch_api.update’ with several contacts with that property with value ‘’ (this is the value to set the property to null) I get the error:
{"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"Values for property \\\"subscription__monthly___coupon_code2\\\" must be unique. Given 2 updates with value \\\"\\\".\",\"error\":\"CONFLICTING_UNIQUE_VALUE\",\"name\":\"subscription__monthly___coupon_code2\",\"propertyValue\":\"\",\"portalId\":24095220}]","correlationId":"342a577c-60d1-4a08-bb5d-67b83ccb48b6","errors":[{"message":"Values for property \"subscription__monthly___coupon_code2\" must be unique. Given 2 updates with value \"\".","code":"CONFLICTING_UNIQUE_VALUE","context":{"propertyName":["subscription__monthly___coupon_code2"]}}],"category":"VALIDATION_ERROR"}
Option A: Change your unique value to a field that will ALWAYS have unique values, such as "id" or "email" - this will allow passing null values in "subscription__monthly" field
Option B: If you are required to have "subscription__monthly" as the unique value, make sure your "subscription__monthly" field always has unique values. Example of option B:
Looking at the error log you provided, what appears to be happening is that when you use the batch upsert, you have multiple records with the same value that is supposed to be unique.
Specifically, it says:
Values for property "subscription__monthly___coupon_code2" must be unique
The error says property "subscription__monthly___coupon_code2" but you mention property "subscription__monthly". So the other thing to check there is which property you actually intend to be the unique one.
Let's just assume you want the "subscription__monthly" to be unique.
Currently your records are:
Record ID 1
'company': 'Power!',
'subscription__monthly': ''
Record ID 2
'company': 'rading',
'subscription__monthly': ''
So if you are using "subscription__monthly" as the unique record, you will receive the error because both records have the same value when the API is expecting unique values there (like an ID cannot be the same for more than one record). It would be the same as if you entered "123" in both records.
That is probably why when you upload in batches of 1, there is no other record to compare to and technically the null value is unique in your batch of 1.
Hope this helps!
✔️ Did this post help answer your query? Help the community by marking it as a solution.
In the Python API ‘’ is the value used to remove the value of a property. That is, it is the way to indicate the absence of value. Even if the property has a single value, you can have several objects with the property set to null. The API should accept sending several records with value ‘’ as it is a special value. I have tried sending None instead of ‘’ but with None the property is not cleared.
Error when modifying multiple contacts with single-valued property with null value
SOLVE
@JMoleroAlonso - both of the subscription properties you mentioned can have whatever value you need it to have - including blank/null - but they cannot be set as the idProperty in the API. Typically the email property is used for that purpose, since two contacts cannot have the same email address.
✔️ Did this post help answer your query? Help the community by marking it as a solution.
The value ‘’ is valid and if I update the registers sequentially there is no problem but if I do it in Batch with BatchInputSimplePublicObjectBatchInput I get the error ‘Values for property “subscription__monthly” must be unique
HTTP response body: {"status":"error","message":"Property values were not valid: [{\"isValid\":false,\"message\":\"Values for property \\\"subscription__monthly\\\" must be unique. Given 2 updates with value \\\"\\\".\",\"error\":\"CONFLICTING_UNIQUE_VALUE\",\"name\":\"subscription__monthly\",\"propertyValue\":\"\",\"portalId\":24095220},{\"isValid\":false,\"message\":\"Values for property \\\"subscription_monthly_referral_link\\\" must be unique. Given 2 updates with value \\\"\\\".\",\"error\":\"CONFLICTING_UNIQUE_VALUE\",\"name\":\"subscription_monthly_referral_link\",\"propertyValue\":\"\",\"portalId\":24095220}]","correlationId":"9b10-db2b4ea09b24","errors":[{"message":"Values for property \"subscription__monthly\" must be unique. Given 2 updates with value \"\".","code":"CONFLICTING_UNIQUE_VALUE","context":{"propertyName":["subscription__monthly"]}},{"message":"Values for property \"subscription_monthly_referral_link\" must be unique. Given 2 updates with value \"\".","code":"CONFLICTING_UNIQUE_VALUE","context":{"propertyName":["subscription_monthly_referral_link"]}}],"category":"VALIDATION_ERROR"}
The field "subscription__monthly" is set as "unique value"
Option A: Change your unique value to a field that will ALWAYS have unique values, such as "id" or "email" - this will allow passing null values in "subscription__monthly" field
Option B: If you are required to have "subscription__monthly" as the unique value, make sure your "subscription__monthly" field always has unique values. Example of option B: