APIs & Integrations

hl_rossato
Member

Unable to update property type through Contact API

I’m trying to update a custom property type through the Contact API but unfortunately with no success.

To do so, I’m following the steps below:
DISCLAIMER: I’m doing these using Python in the console.

1 - Getting the property details using the Contact API

response = requests.get('https://api.hubapi.com/properties/v1/contacts/properties/named/registration_date?
                         hapikey=apikey')
response.json()

2 - Update the details I need (I need to update the property type from date to datetime)

{ u'calculated': False, u'createdUserId': 2735449, u'deleted': False, u'description': u'Date when client was onboarded on the platform', u'displayMode': u'current_value', u'displayOrder': -1, u'externalOptions': False, u'favorited': False, u'favoritedOrder': -1, u'fieldType': u'text', u'formField': True, u'groupName': u'platform_data', u'hidden': False, u'label': u'Registration Date', u'mutableDefinitionNotDeletable': False, u'name': u'registration_date', u'options': [], u'readOnlyDefinition': False, u'readOnlyValue': False, u'showCurrencySymbol': False, u'type': u'datetime', u'updatedUserId': 4975228 }

3 - Sending a PUT request to the Contact API with this new data

response = requests.put('https://api.hubapi.com/properties/v1/contacts/properties/named/registration_date?
                         hapikey=apikey', data=json.dumps(data))

4 - The response is coming with 200 code. However, I’m trying to access response.json() I’m getting this error: JSONDecodeError: Expecting value: line 1 column 1 (char 0)

What I did then was repeating the step 1 but I’ve got the same previously response with same data.
I’ve also tried to update the description of the property following the same approach just to check if was something wrong with the datetime but it didn’t work either.

0 Upvotes
3 Replies 3
hl_rossato
Member

Unable to update property type through Contact API

@VincentTheeten I’ve made it work. What I did was create a headers dictionary like the one below and pass it on the PUT request.
headers = {"Content-type": "application/json"}

I don’t know why but it worked after this.
Hope that works for you too.

0 Upvotes
Not applicable

Unable to update property type through Contact API

That works! Thanks for the help.

Not applicable

Unable to update property type through Contact API

I have the same thing.

Also tried creating a brand new property with type=datetime

POST to https://api.hubapi.com/properties/v1/contacts/properties?hapikey=xyz

{'fieldType': 'date',
 'groupName': 'conversioninformation',
 'label': 'Some bla',
 'type': 'datetime'}

Returns status code 200 but also doesn’t have a body (so JSON deserialization fails)

Also, when I go and check, the property has not been created

0 Upvotes