Solved

How to get the URL to a topic by id?

  • 16 October 2020
  • 3 replies
  • 239 views

I’m fetching a list of topics via the API (https://api2-us-west-2.insided.com/docs/community/#operation/getTopicList) but I have no idea how to generate the URL to link to so that the user can see the post and replies.

Any hints?

icon

Best answer by ronnbot 16 October 2020, 20:53

View original

3 replies

Figured it out: HOST/topic/show?tid=${data.publicId}&fid=${data.categoryId}

I saw this URL format when hovering on a search result. 

Badge

Thanks for sharing your solution @ronnbot - however, I don’t think it will work.

The ID shown in the URL on the community is different to the IDs returned in the API.

I’d propose following this guidance from our API docs (quoting it for convenience here - the source of truth is in the API docs, however :)):

The Community API provides different URLs for articles, questions and conversations than the actual community website. This is because the community website uses SEO-friendly URLs containing a global ID which does not match the article, question or conversation ID (local ID). The community website redirects API URLs to the SEO-friendly URLs.

/conversations/<local-id> will be redirected to /category-name-<category-id>/conversation-title-<global-id>

Local and global IDs also apply to replies and their URLs.

/questions/<local-id>/replies/<local-reply-id> will be redirected to /category-name-<category-id>/question-title-<global-id>#postid/<global-reply-id>

 

In summary, you’ll end up with a URL like this:

https://community.insided.com/questions/451

See the last paragraph of this part of the API docs for the source: https://api2-eu-west-1.insided.com/docs/#section/Community).

@daniel.boon  Hi Daniel, do we have a solution for this question yet? I have logged into the back end with hope that I could find the api id for a post but unfortunately I couldn’t find the id. (I could retrieve the api id for “users” though). 

Reply