5

I am trying to see and show whether a comment on question/answer is flagged by the authenticated user.

  1. But whenever I use /questions/{ids}, can_flag is true irregardless of whether the user (me) can actually flag the comment.
  2. When I use /comments/{ids}, I get the correct status.
  3. Editors note: additional/updated/different info in the answer below, but this still looks like a set of bugs.

Example:

  1. For The API Sandbox question on Meta Stack Exchange:

  2. In this answer there (Id 54725), I flagged the (now deleted) comment with ID 764560 (Link now works only for SE devs and MetaSE moderators).

  3. But the /questions/{ids} route shows can_flag: true, which is incorrect:

    questions route shows incorrect can_flag


  4. However, using /comments/{ids} I get can_flag: false, which is correct:

    comments route shows correct can_flag for flagged comment


  5. I also tried /comments/{ids} for an unflagged comment (comment ID:396655). It givescan_flag: true, which is correct:

    comments route shows correct can_flag for unflagged comment

Why is there an inconsistency? This looks like a bug.


Note: I did (re)check /questions/{ids} 30 minutes after flagging the comment. So this does not seem to be a time-delay/caching issue.

1

I can't replicate the bug as stated; both /questions/{ids} and /comments/{ids} give the same results which are:

  1. can_flag is false for my comments.   (Correct behavior)
  2. can_flag is true for comments posted by others.   (See next item)
  3. can_flag is true even for comments that I have an active flag on.   (Wrong behavior)


Steps to replicate:

  1. Go to this API OAuth page and authorize the application.
  2. From the resulting value in your browser's address bar, copy out the access_token value.
    For example, if your browser is redirected to:

    https://stackexchange.com/oauth/login_success#access_token=OGuIJlBxxxMkj2Ola1jG1A))&expires=86400
    

    You want the OGuIJlBxxxMkj2Ola1jG1A))

  3. Find a question with a comment you can legitimately flag; perhaps the sandbox question on MetaSE.

  4. Add your own comment there.

  5. Flag a single comment that legitimately deserves it (if any).

  6. Visit this page in your browser (After updating the access_token):

    https://api.stackexchange.com/2.2/questions/3122/?access_token={INSERT VALUE FROM STEP 2 HERE}&site=meta&key=dp55hR5Wr9UhOJReA6F2gg((&filter=!pL7rWh2ni*lt.6(Pbf6bqCepl*I4sG)2VFlDiXzeex7895bjn0p3NcCGHCZb28uVIY
    

    It helps if you use Firefox or a browser/extension that formats the JSON for you.

  7. Note that can_flag is false for your comment. (Correct)

  8. In the JSON, find the comment you previously flagged (hopefully the comment and flag both still exist). Copy its ID.

  9. Visit this page in your browser (After updating the comment ID and the access_token):

    https://api.stackexchange.com/2.2/comments/{INSERT VALUE FROM STEP 8 HERE}?access_token={INSERT VALUE FROM STEP 2 HERE}&site=meta&key=dp55hR5Wr9UhOJReA6F2gg((&filter=!1zSn*g7xPUqB4hiVTpmJB
    
  10. Note that the comment's can_flag still shows as true -- which is incorrect.

  11. Delete the comment you made in step 4, if appropriate.

  12. Your access_token will expire in 24 hours. Or you can deauthorize the app by following these instructions.

  • I forgot that i posted a question. the API Browser works fine. The issue is when i do a REST call, i need to include parameter todate and always post the current second like Math.Floor(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds) and it always brings the current status. This also happens with Questions api call. If you do not pass todate, you will keep receiving same questions over and over. Again this is only in REST Side. from API Browser it works fine. – AVK Aug 27 '18 at 12:53
  • @AVK, I don't see how that last comment is related to your bug report here at all. – Brock Adams Aug 27 '18 at 17:32
  • IDK How SE is caching the calls but if i do not pass the parameter and if i make any number of subsequent calls, it always comes back as true. When i posted this question, i mentioned i tried after 30 mins. When i made the call after 30 mins, without the parameter, it comes back true. But if i pass the parameter todate with the value above, it comes back as false. You can see this in Stack10. – AVK Aug 27 '18 at 18:01
  • @AVK, there is no mention of any date parameter in your original bug report, nor the comment. ... And it does not seem necessary to replicate this bug (as outlined in the answer, anyway). – Brock Adams Aug 27 '18 at 18:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .