ariznaf
(fernando)
January 14, 2022, 6:17pm
1
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
pfaffman
(Jay Pfaffman)
January 14, 2022, 7:28pm
2
The best documentation for the API is discourse. See How to reverse engineer the Discourse API
4 Likes
ariznaf
(fernando)
January 15, 2022, 7:09am
3
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
ariznaf
(fernando)
January 15, 2022, 10:20am
5
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
fzngagan
(Faizaan Gagan)
January 15, 2022, 2:27pm
6
i would expect it to work that way.
5 Likes
ariznaf
(fernando)
January 15, 2022, 5:08pm
7
Thanks we will try, I will talk with the programmer.
2 Likes
mattdm
(Matthew Miller)
January 16, 2022, 1:53pm
8
See
Sure, the included badges are … nice. Nothing wrong with them at all. But, what if you want more? What if you want to go beyond the pre-defined symbol set? Sure, there’s an admin page where you can upload them. But what if you want to make a whole lot of badges ?
Well, good news! You can do this through the API. Here’s Python code showing how it works. (And it awards the badge at the end, for good measure.)
This should be pretty easy to read even if you’re not a Python programmer. You can even …
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