Upload image on wordpress by api

I want to upload images on WordPress by API.can anyone help me to solve that.i will ready to pay

i tried this

& getting this error

here is the solution.i want to do that on kodular

curl -sk --request POST --url http://tutorialspots.com/wp-json/wp/v2/media --header "cache-control: no-cache" --header "content-disposition: attachment; filename=file.png" --header "authorization: Basic $base64credentials" --header "content-type: image/png" --data-binary "@/fullpath/file.png" --location

Any link to the api?

Not by API i know using ftp if you want.

i want image id after upload.i want to added this on wordpress post

exactly! @msr79526 please provide a link to the API documentation… the documentation has been written for a purpose…

according to your curl example, Authorization Basic is used, also the filename is not surrounded with double quotes there… and I would try the PostFile block together with the image

Taifun

Here is the api docs link.

& that docs doesn’t elaborate more.you can found soo much resources on google.but they are in php. & i haven’t much knowledge about file upload.i tried without quotes. But same result.

there still is no api docs link in your post…

it looks like you did not follow all suggestions… especially it looks like you ignored using the PostFile method suggestion… and if you try something new, then it would help to post a screenshot of your updated blocks…

Taifun

2 Likes

I tried this & showing a direct error that can’t post a file on this URL.this API need image in bytes

Error

finally we have an API documentation… :partying_face:
can you explain, what you are trying to do? creating a media item?

as a start, you could first try the LIST option, which should be simple to implement
GET /wp/v2/media
like this you can test, if your Authorization headers are correct…
and if you got that running, then continue with your other task…

and concerning Authentication, I would follow this

and use Basic Http Authentication…
see also here App Inventor Tutorials and Examples: File Download | Pura Vida Apps

Taifun

i already auth by jwt auth & using that token

i can get without authentication.i need post solution.to get i didn’t need to implement disposition in header but when i have to post then i have to use it

did you get the LIST option running together with your Authentication?
Taifun

without authentication i can get media.

get

.with this authentication i post blog post

probably one of these threads can help? https://stackoverflow.com/search?q=[wordpress]+file+type+is+not+permited+for+security+reasons
and in the header I would remove the double quotes around the filename…

Taifun

i read about this.you can see that i am uploading image .that was accepted by api.but shwoing this error.means i did wrong in block

For me, I’ve managed to upload to my WP site using WP “Application Password” and by following this guide.

and this is the blocks

3 Likes

I didn’t test it.but i think it will work it is.thank you

1 Like

showing an error

I tried this

Could it be something with the “auth by jwt” you are using? Mine works with “application password” which now builtin inside wordpress. I never used jwt for WP REST API.

Ok.i will cheak with that.can you sharean demo text of it. I don’t know how it should be