Hi @bengreeley,
Thank you very much for your reply.
I know the REST API and the code that I made is as the following, but I donot know where I should set the image to be uploaded to my WordPress website, the image that I need to upload on cdn server
headers.set("Content-Type","application/json");
headers.set("Authorization","Basic "+Buffer.from(<code>${ourUsername}:${ourPassword}</code>).toString("base64"));
headers.set("Content-Disposition","attachment; filename='public-page-logo1.png'");
fetch("mywebsite/wp-json/wp/v2/media",{
method:"POST",
headers:headers,
body:JSON.stringify({
title:"post feature image1",
status:"publish",
media_type:"image",
ping_status:"open",
alt_text:"File upload",
caption:"Caption upload"
})
}).then((response) => response.json())
.then((data) => console.log(data));
-
This reply was modified 2 years, 3 months ago by georgenasim.