• Resolved giupix

    (@giupix)


    I added new posts fields and I can read and edit with Rest api, but when I try to add a Media field I can read but not modify it with rest api calls. I have enabled rest api read / write of course.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    I’m looking at this today and will let you know what I find out here.

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    I’ve looked into this using the following details for my test:

    • Created Custom Post Type
    • Added a File upload field
    • Added a Relationship field (related to media)
    • Enabled REST API and read/write for all fields

    After setting up that configuration, I tried making REST API requests to update an CPT item. This test included updating the file/relationship fields while they had NO value as well as changing the value to another file ID.

    When I make the requests, I send the file_field_name and relationship_field_name as the ID of the file that I am wanting to send.

    I can also save “no value” to the fields through REST API by sending an empty value for those fields or “0”. Both of those cases worked as expected.

    Is your media field set to output as Full or ID only? Try switching and see if that changes anything for you. I have a fix coming in an upcoming release of Pods which resolves a problem where relationship fields related to Media would not output the full data if you did not already extend Media with Pods.

    Thread Starter giupix

    (@giupix)

    Hi Scott,
    thanks for the help, in my case the problem happens when I extend Media type with a text field.

    Schermata-2021-05-12-alle-17-22-53

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Thanks for clarifying, I was able to reproduce your issue here. I’m looking into a solution for our upcoming release.

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Fixed in Pods 2.7.28 which will be out next week. You can get an early release of that from our GitHub repo here: https://github.com/pods-framework/pods/archive/refs/heads/release/2.7.28.zip

    Note: This is a pre-release and the version number is 2.7.28-a-1. You’ll still see an update notice in your WordPress dashboard when the official version is released.

    Thread Starter giupix

    (@giupix)

    Hi Scott,
    I tried the update and it works great now! Thank you.

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    Awesome!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Add Media field -Rest api problem’ is closed to new replies.