Update media using REST API

Question

I am trying to update media items data (title and ACF fields) using the REST API.

I am trying the same method that I successfully used to update ACF data for post types. But it isn’t working for media..

    const route = `${API_URL}media/${id}`;
    const body = {
        status: 'publish',
        fields: {
            job_code: `${job_code}`,
        },
    };

    const res = await fetch(route, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            Authorization: `Bearer ${token}`,
        },
        body: JSON.stringify(body),
    });

From this answer from 2018 it appears that it isn’t possible.

I’m wondering whether it is now possible, and if not, what possible workarounds there are to achieve it.

0
Darcy 1 month 0 Answers 10 views 0

Leave an answer