File uploads in cloneable groups in not showing in Rest

Support MB REST API File uploads in cloneable groups in not showing in RestResolved

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #47646
    Marcus PottsMarcus Potts
    Participant

    Hi

    I multiple fields with file uploads, some of which are part of cloneable groups.

    I am integrating this with a CRM system and need to make the file paths available to this system using Rest. File uploads (even with multiple files) show nicely in the JSON:

    
    "environmental_sustainability_policy":[
             {
                "filesize":398120,
                "ID":"6203",
                "name":"xxxxxxx.pdf",
                "path":"\/var\/www\/vhosts\/xxxxxxx\/httpdocs\/wp-content\/uploads\/2025\/02\/xxxxxxx.pdf",
                "url":"https:\/\/xxxxxxx\/wp-content\/uploads\/2025\/02\/xxxxxxx.pdf",
                "title":"xxxxxxx"
             },
             {
                "filesize":14304,
                "ID":"6204",
                "name":"xxxxxxx.xlsx",
                "path":"\/var\/www\/vhosts\/xxxxxxx\/httpdocs\/wp-content\/uploads\/2025\/02\/xxxxxxx.xlsx",
                "url":"https:\/\/xxxxxxx\/wp-content\/uploads\/2025\/02\/xxxxxxx.xlsx",
                "title":"xxxxxxx"
             }
          ],
    

    But when the fields are part of a group, only the media ID is returned:

    
          "accreditation_details":[
             {
                "accreditation_name":"CHAS",
                "upload_accreditation_document":[
                   "5864",
                   "5865"
                ],
                "accreditation_other_expiry":{
                   "timestamp":"1834963200",
                   "formatted":"24\/02\/2028"
                }
             }
          ],
    

    Please can you help.

    Thanks
    Marcus

    #47651
    PeterPeter
    Moderator

    Hello Marcus,

    That is expected. The subfield value in a group saves only the raw value. It is the media file ID in this case.
    So it doesn't return meaningful value like when you use the field as a top field (outside of a group field). I suggest you create a custom route and use the function RWMB_File_Field::file_info( $image_id ) to get the file info and send it via Rest API.

    Following the documentation https://docs.metabox.io/extensions/meta-box-group/#sub-field-values

    #47671
    Marcus PottsMarcus Potts
    Participant

    Hi Peter

    Thank you for pointing me to that solution. I have registered a new REST field and retrieved the document details using your function which now outputs perfectly in my new field.

    Thanks
    Marcus

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.