I’m currently writing an API on Python.
Goal: Update repeater field. I can change anything else(like text), but working with repeater fields came in a bit of a struggle. For authorization, I’m using the JWT token. ‘cadres’ field doesn’t want to update.
please help 🙁
curHeaders = {
"Authorization": "Bearer %s" % jwt_token,
"Content-Type": "application/json",
"Accept": "application/json",
}
test = ['http://localhost:8888/wp-content/uploads/2021/06/test.jpeg']
postDict = {
'fields': {
'videos': {
'fields': {
'title': 'This is working properly',
'fields': {'cadres': test
}}}}}
lollookatthis = requests.put('http://localhost:8888/wp-json/acf/v3/custom_post/369', headers=curHeaders, json=postDict)
The post/put action returns a JSON with an updated value of ‘title’, but not an updated value of ‘cadres’. It doesn’t return an error, so the post/put request is working as intended, perhaps it’s just the way that ACF works.
I have no idea how this ties into what you are doing, but if you are attempting to update ACF values for fields that do not already have a value stored in the DB for the post being updated then you must use the field key when updating using the acf function update_field() and if you are not useing this function then you must also create the acf field key reference value.
see this document where it talks about using the field key https://www.advancedcustomfields.com/resources/update_field/
for every field, for example “$field_name” a second second value is added to the db with the meta_key of “_{$field_name}” and the value of this second entry is the field key of the field. This field key reference must exist for anything except basic text fields.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.