APIs & Integrations

JMoleroAlonso
Member

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"}

 

[
{'id': 1, 'properties': {'company': 'Power!', 'partner': 'true', 'firstname': 'Abrm', 'phone': None, 'subscription__monthly': '', 'subscription__monthly___referral_link': '', 'subscription__non_monthly': 'SNPRO', 'subscription__non_monthly___referral_link': 'https://www.test.com?fpr=dpa&coupon=SNPRO', 'user_country': None, 'website': None}},

 {'id': 2, 'properties': {'company': 'rading', 'partner': 'true', 'firstname': 'rading', 'phone': None, 'subscription__monthly': '', 'subscription__monthly___referral_link': '', 'subscription__non_monthly': 'PST', 'subscription__non_monthly___referral_link': 'https://www.test.com?fpr=dpa&coupon=PST', 'user_country': 'ES', 'website': 'https://www.tradingaldia.com'}}
]

 The property I am trying to update and having problems with is "subscription__monthly", which I am sending as 

'subscription__monthly': ""

 

If instead of updating in ‘batch’ I update the contacts sequentially (or with batches of size 1), no errors occur.

 

Is this a bug in the API or is it expected behaviour?

 

Thank you!

0 Upvotes
1 Accepted solution
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @JMoleroAlonso,

 

As I had mentioned in previous messages, you cannot set the field as "unique value" if there is a change that field values will be the same.

 

To illustrate, this is NOT unique because values for "subscription__monthly" are identical:

{ ‘id’:‘record1’, ‘subscription__monthly’: ''}
{ ‘id’:‘record2’, ‘subscription__monthly’: ''}

 

To resolve this issue you have two options:

 

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:

{ ‘id’:‘record1’, ‘subscription__monthly’: 'null_1'}
{ ‘id’:‘record2’, ‘subscription__monthly’: 'null_2'}

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

View solution in original post

0 Upvotes
8 Replies 8
evaldas
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @JMoleroAlonso,

 

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.

0 Upvotes
JMoleroAlonso
Member

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @evaldas ,

 

subscription__monthly___coupon_code2 and subscription__monthly. I forgot to rename them in the log.


@kennedyp  The field is of type single-text.

 

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.

 

Thank you!

0 Upvotes
evaldas
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

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.

0 Upvotes
JMoleroAlonso
Member

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @evaldas 

The problem arises when in the BatchInputSimplePublicObjectBatchInput method I send 2 inputs with the same property with value ‘’.

[
{ ‘id’:‘record1’, ‘subscription__monthly’: ''}
{ ‘id’:‘record2’, ‘subscription__monthly’: ''}
]

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

0 Upvotes
evaldas
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Can you share the full API call that you are using?


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes
JMoleroAlonso
Member

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @evaldas ,

this is the call I perform from Python

batch_input_simple_public_object_batch_input = BatchInputSimplePublicObjectBatchInput(inputs=chuck)
api_response = self.client.crm.contacts.batch_api.update(
    batch_input_simple_public_object_batch_input=batch_input_simple_public_object_batch_input)
response_results: list[SimplePublicObject] = api_response.results

 

 The content of "chuck" is:

[{'id': 216006776, 'properties': {'company': 'Power!', 'd_zero_partner': 'true', 'firstname': 'Abraham', 'phone': None, 
'subscription__monthly': '', 'subscription_monthly_referral_link': '', 'subscription_non_monthly_coupon_code': 'PRO', 
'subscription_non_monthly_referral_link': 'https://www.domain.com?fpr=dpwua&coupon=PRO', 'user_country': None, 'website': None}}, 
{'id': 216018862, 'properties': {'company': 'Day', 'd_zero_partner': 'true', 'firstname': 'Day',
 'phone': None, 'subscription__monthly': '', 'subscription_monthly_referral_link': '', 'subscription_non_monthly_coupon_code': 
 'PRE', 'subscription_non_monthly_referral_link': 'https://www.domain.com?fpr=dpwua&coupon=PRE', 'user_country': 'ES',
  'website': 'https://www.day.com'}}]

 

And the error message is:

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" 

 

thank you!

0 Upvotes
evaldas
Solution
Key Advisor | Platinum Partner
Key Advisor | Platinum Partner

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @JMoleroAlonso,

 

As I had mentioned in previous messages, you cannot set the field as "unique value" if there is a change that field values will be the same.

 

To illustrate, this is NOT unique because values for "subscription__monthly" are identical:

{ ‘id’:‘record1’, ‘subscription__monthly’: ''}
{ ‘id’:‘record2’, ‘subscription__monthly’: ''}

 

To resolve this issue you have two options:

 

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:

{ ‘id’:‘record1’, ‘subscription__monthly’: 'null_1'}
{ ‘id’:‘record2’, ‘subscription__monthly’: 'null_2'}

 


✔️ Did this post help answer your query? Help the community by marking it as a solution.

0 Upvotes
kennedyp
Community Manager
Community Manager

Error when modifying multiple contacts with single-valued property with null value

SOLVE

Hi @JMoleroAlonso! Welcome to the Community-- happy to have you here 😊

 

Can you clarify what field type the subscription__monthly property is? Is this a single-line text? 

 

@SteveHTM notes in a similar thread that enumeration values that have been cleared may return as "" as opposed to "none": Difference between null and "" in contact property value

 

I want to invite some subject matter experts to see if they have any suggestions.

Hey @evaldas, @GRajput have you experienced this error with batch upserts? Any troubleshooting advice?

 

Best,

Kennedy


Did you know that the Community is available in other languages?
Join regional conversations by changing your language settings !