How to mark Topic or Notification as "Read = true"

AI-generated summary

Marking Topic or Notification as “Read = true” via Discourse API

Edwin_Mhoy_Silva is working with the Discourse API and is having trouble marking topics and notifications as viewed since they are not being directly accessed. joebuhlig suggested making an API call to the endpoint https://github.com/discourse/discourse/blob/70fdc10365/config/routes.rb#L646 to mark posts as viewed.

However, Edwin_Mhoy_Silva asked for clarification on how to use this endpoint, and codinghorror explained that it would mark the posts as viewed. To make the API request, Falco recommended reading a guide on reverse-engineering the Discourse API, and joebuhlig suggested following the code back to the controller.

Falco provided a sample cURL request to the timings endpoint, which includes the necessary headers and data. Edwin_Mhoy_Silva shared a screenshot of their network tab, showing the request data. ryze1, natasha_selvidge, and manojm321 asked for clarification on the timings variable and its values.

The timings variable is still unclear, and its values are not explicitly explained. However, it appears to be related to the time spent on the topic, and the API request requires specific data to be sent in the request body.

I´m working with the Discourse API.
The website I’m working on gets all the data from the Discourse API. I’m having the issue that because I’m actually not viewing the Topics and Notification, and only getting data through the api, then my topics and notification are not registered as viewed.

How should I solve this issue?

If I’m following, you need to make an API call to this endpoint:

Thanks for the reply.
How would this post request help me?

It will mark the posts as “viewed”, which is what you wrote in the first post.

How should the api request look like ?
something like this?
{{base_url}}/t/timings/topic_Id.json?

Please read Reverse engineer the Discourse API

You could start with following the code back to the controller. Everything you need to know about the method is there.

I already tried do the reverse engineering.
The only response i get from the network tab is
{{baseurl}} + /t/3295.json?track_visit=true&forceLoad=true&_=1550774445459

You gotta read it carefully.

Right clicking a request to timings and selecting copy a cURL will give you all you need for a request using the cURL syntax (the standard format for most people):

curl 'https://meta.discourse.org/topics/timings'  \
    -H 'Accept: */*' \
    -H 'Accept-Language: en-US,en;q=0.5'  \
    -H 'X-CSRF-Token: LONGTOKENHERE' \
    -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
    -H 'X-SILENCE-LOGGER: true' \
    -H 'Discourse-Logged-In: true' \
    -H 'Discourse-Visible: true' \
    -H 'X-Requested-With: XMLHttpRequest'  \
    --data 'timings%5B3%5D=1019&timings%5B4%5D=1019&topic_time=1019&topic_id=108685' \
    --compressed

This is what I got from the network tab


What is the the number beside the timings variable?

Hi Edwin, did you figure out what this timings variable was an dhow to set it? have same problem.

Hi Edwin, did you figure out how to get the data? timings and topic_time? or how to get it work? I have the same issue. Thanks!

can someone please explain what the value of timings and topic_time are? is that seconds spent on the topic?