How to replace an image in WordPress via REST API 2.0?
<p>I have some images uploaded on a WordPress site that is to be completely REST controlled and I'm having trouble updating them. Altering image data is simple, via <code>POST</code> requests to <code>.../media/&lt;id&gt;</code>, but I can find no way to actually replace the image <strong>content</strong> with another file.</p>

<p>Of course, I could delete such an image, <code>POST</code> the new file as new media, and re-<code>POST</code> the old data (name, alt), but this seems ugly, and will mess up my media IDs references in posts that used the old one (and should now use the new one).</p>

<p>So, is there a neat way to replace one image's content with another, without deleting media (i.e., without changing media's ID)?</p>

<p>I am using Python for this, but <code>curl</code>'s command line is also fine, easy to translate to Python.</p>

<p>It seems that this <a href="https://github.com/WP-API/WP-API/issues/2715" rel="nofollow">cannot be done</a> and the media records have to be deleted and recreated.</p>

python wordpress rest api curl