Get ID for updating a post

(Nisbeti) #1

When creating a new category, I must have an automatically created post, as: Every category has an initial "About this category" topic.
So, I use the API to create the ‘group one’ category, then I get the topic-url from the result, and I can then use the API to change the title of the “About this category” topic.
curl -X PUT -d title="This is my new title for group one category" -d api_key=blahblah -d api_username=system http://localhost:3000/t/about-the-group-one-category/20

I can then use the API to get the latest posts in that newly created category,
which gives me the default post and its id. If the id of the post is 55, then I notice that (using the reverse engineering approach), the id that must be updated is the id + 3 = 58

So, I can use this to change the default text of the post:
curl -X PUT -d post[raw]="This is the new text for the About this category initial post" -d api_key=blahblah 7 -d api_username=system http://localhost:3000/posts/58

Is there a better way to get the id for updaing, or can I be certain that it will always be the post id + 3?

(Tom Newsom) #2

Why not just do http://localhost:3000/t/about-the-group-one-category/20.json and pull the id from the first post?

(Nisbeti) #3

Thanks Tom, this lead me to find that http://localhost:3000/t/20.json also works, so the slug is not needed, only the id