Batch Updates - Python

I am trying to perform a simple batch update using the recommened python package hubspot-api-client.

My expectation is that I could create a list of dictionaries with the id and properties and use them as below:

from hubspot.crm.companies import SimplePublicObjectInput

from hubspot.crm.companies import BatchInputSimplePublicObjectBatchInput

companies_to_update = []

for company in companies:

companies_to_update.append(SimplePublicObjectInput(properties={

“id”: “12345”,

“level”: “good”

}))

objects_input = [CompanyObjectInput(**obj) for obj in companies_to_update]

batch_input = BatchInputSimplePublicObjectBatchInput(inputs=objects_input)

response = api_client.crm.companies.batch_api.update(batch_input)

However, when I try this, the api responds that id is a required field. If I instead move [id] out of properties and into kwargs, then python barks at me that id is not an expected kwarg.

This would seem to me a very common use case which I can’t seem to get to work? Can anyone spot what I’m doing wrong?

Hi, @APopp3 :waving_hand: Welcome to our community. Were you able to get this worked out?

Best,

Jaycee

Hi Jaycee,

Thanks - no such luck trying to get this to work using the recommended python library. I think it might be more straightforward to just use the api without the library, although if someone were able to point out a solution with the library, that would be best, as I’m sure I would be losing out on many side benefits by not using the library.