HELP - Upload feature image to Post wordpress

Hi, How to Set a Featured Image in WordPress??

Url: https://superrealreviews.com/wp-json/wp/v2/posts/ID_POST_TO_UPDATE

Name: featured_media
Value: {{ $json.yoast_head_json.og_image[0].url }}

image

Hey @Edgard_Neto,

That looks like the URL you are calling is incorrect, Have you verified that it is correct? Wordpress seems to think the URL is wrong so I would start with that.

@Jon

Hi jon, do you refer to this link?

/wp-json/wp/v2/posts/ID_POST_TO_UPDATE]

should i use this one? /wp-json/wp/v2/media

Hey @Edgard_Neto,

Assuming you have added the image to the post it should then be /wp-json/wp/v2/posts/id but in your error Wordpress is saying it is not correct so it could be that your post id is wrong or your featured_media data is incorrect.

Looking at the image again you are sending a URL and it should be the ID you get back from uploading the file to Wordpress.

@Jon

I’m using: /wp-json/wp/v2/posts/id

Name: featured_media
Value: {{ $json.id }}

I tested it on several articles and nothing, same error.

See the image path starting with Code:

Image from wordpress:

image

Still waiting for a possible help! I’ve done several tests and I don’t know what happens.

:grinning: :sunglasses: :student:

Hey @Edgard_Neto,

Sorry we are not that active over weekends as we like to take a couple of days off :wink:

Looking at the images it looks to be ok but Wordpress is still saying you have an issue, Can you share the actual URL you are using as I still can’t see it in any of your images.

My current thought is you are actually using /wp-json/wp/v2/posts/id and not replacing the id text to the acutal ID number of the post you are trying to update. This is also why we ask for the actual workflow to be shared in the template as it will typically speed up fixing issues like this.

1 Like

you have to upload the image first to Wordpress and then set its number as the featured image.

Make a POST request:

https://www.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.com/wp-json/wp/v2/posts

image

1 Like

@Jon @RedPacketSec

I will share everything with you, hope it helps.
Here is the flow:

Media Library:

I understand that you only need the number. But if I just get the number and put it in the HTTP after the wordpress node, it doesn’t work, it gives an error, it says that I can’t get very long data.

And I need to put a code to pull new numbers, because each post is a different number.

How do I make this image number, which appears in the initial node of the “Download file” reach wordpress.

@ManyQuestions

Perfect so that looks like a different error, This time the error is with the number you are sending, Assuming it is just the one item at a time for the featured_media value you should be able to use something like {{ $('Upload IMAGE 1').first().id }}

I also have the problem, that my posts are not taking the correct ID. They always take the ID of the last picture, that is uploaded. How can i take the first one?

SCR-20230731-pelq

@ManyQuestions I suspect for you it could be in the data, Would it be easier if I just update the Wordpress node to include media uploads and setting a featured image?

1 Like

@Jon

yes, update the wordpress node and include the “featured image” field. It will be very useful for us.

Thank you, I look forward to wordpress node update.

@Jon I’ve tried using the links with "Upload IMAGE “HTTP Request” and the system accepts it, but nothing appears.

image

this is what i do:

image

image

Hey @Edgard_Neto,

Looks like I missed out the .json part in the expression, Try {{ $('Upload IMAGE 1').first().json.id }}.

@RedPacketSec

does this ID appear inside the wordpress node?? where do you pull it from?