georgenasim
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Fixing WordPress
In reply to: Media by rest apiHi @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 serverheaders.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 3 years, 9 months ago by georgenasim.
Forum: Plugins
In reply to: [Media Library Folders] How to use API to upload imagesHow to uplaod image tp wordpress by rest api I tried this codefetch(“https://…./wp-json/wp/v2/media”,{
method:”POST”,
headers:headers,
body:JSON.stringify({
title:”post feature image”,
link:”https://cdne-c…..png”,
source_url:”https://cdne-c…..png”,
status:”publish”,
media_type:”image”,
description:””})
});`
Viewing 2 replies - 1 through 2 (of 2 total)