Create New Entry Python API (Array field(List))

I am trying to use the Python SDK to programmatically create entries. I am running into errors when trying to update List type fields. Is my syntax off? I have created entries using this code already so I know it’s connecting and uploading fine. Im positive it is a syntax error. Code will be below.

from handler.toolkit import *
import numpy as np
import codecs, json

entries = entryClient.entries()

entry_attributes = {
‘content_type_id’: ‘seanTest2’,
‘fields’: {
‘listField’: {
‘en-US’: []
}
}
}

new_entry = client.entries(‘oqdu9tolm6fg’, ‘master’).create(
‘new_entry_id’,
entry_attributes
)

new_entry.save()

It looks like you aren’t specifying any data in the list field… Maybe try adding some string values to the array? Like so:

entry_attributes = {
    'content_type_id': 'seanTest2',
    'fields': {
        'listField': {
            'en-US': [
                'one',
                'two',
                'three'
            ]
        }
    }
}

new_entry = client.entries('oqdu9tolm6fg', 'master').create(
    'new_entry_id',
    entry_attributes
)
1 Like

Thanks! I had got it working.