Is there an API call to set the logo image of a category?

We use API calls from an external program to create some topics authomatically.

We now want to change authomatically the logo image of some categories, extracting the image from some posts previously created in discourse.

But in the API documentation we could find no option to set the logo image of categories, just color, name or text color.
Discourse API Docs

Is there a way to do that?
Are we looking a the wrong place in documentation?

Thanks in advance.

1 Like

The best documentation for the API is discourse. See How to reverse engineer the Discourse API

4 Likes

Thank you, I will have a more in depth look.
It seems you can analize it using the developers tool of the browser.
But with the logo image of a category there is no edit mode, just a button to open a dialog box to select it, and I don’t see in the browser what field discourse is updating.

The problem I am having is that there is no PUT method to set the logo.

There is a POST method where you can stablish all the cateory properties.

But that POST method is for creating a category, not for updating it and change the category properties.
May be it can be used in some way to update the category.

1 Like

Its a two step process.

  1. When you upload a logo, the uploads.json endpoint is called with the image. If its sucessful you get a id in the response.
  2. Now you call the endpoint you were seeing and use the param uploaded_logo_id with the id you got in the previous step.
6 Likes

thanks a lot.

I have been trying to reverse engineer it using the developer tools of browser.

Yes it seems that you first use uploads.json to upload it.

I our case the image is already in the system, as it is a photo embeded in a post, so I imagen we can get the id from the post.

And the you just need to use the PUT method to https://foro.ojodigital.com/categories/{cat_id}?
with the uploaded_logo_id={image_id} with no other info?

Thans, will try.

3 Likes

i would expect it to work that way.

5 Likes

Thanks we will try, I will talk with the programmer.

2 Likes

See

for an example of using the new image upload API in Discourse. It’s for a different purpose but the same probably applies.

1 Like

Great, thanks a lot.