Support

Account

Home Forums ACF PRO ACF-TO-REST-API with Python | Repeater fields not updating

Solving

ACF-TO-REST-API with Python | Repeater fields not updating

  • 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.

  • This reply has been marked as private.
  • 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.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.