Votes on issues not registering

Issue #107 resolved
David Marrs created an issue

Originally raised with Andre on 26th Sept. Might already have been fixed in commits that evening (I can't currently log in to test, so apologies if that's the case)

I'm having a little issue with the Voting API (possibly because http://api-dev.udemi.org/docs/ is a little hard to read at the moment).

Currently in the UI a user can vote up by clicking the thumbs up button, or can change their mind and vote down by clicking the thumbs down button. I assume that the API works in the same way, that a POST to /v1/likes/{pk}/vote_down/ will replace a previous POST to /v1/likes/{pk}/vote_up/. However, there is a 3rd state in the UI: rather than clicking the thumbs down button, the user could click the thumbs up button again, and this causes there vote to be unset (neither thumbs up nor thumbs down is marked as selected: the user is neutral). Is there an equivalent method to unset a vote in the API? Or, for now, should I disable the functionality to unset a vote in the UI?

Also, I don't think my votes are filtering through to the /v1/issues/ API method (e.g. http://api-dev.udemi.org/v1/issues/?latitude_south=51.19110090436095&latitude_north=52.158482789744944&longitude_west=-3.008849540624965&longitude_east=0.6495977250000351): looking at the relevant issue in the returned object the upvotes and downvotes properties are still set to 0 (and the user_vote property is null).

I was making a POST request with a header "Authorization:Bearer RUtZC8kv4Q1c21H79mNJIfooHTcLmz" which got a response {"vote_id":"issues.issue.18:15","user_id":15,"target_content_id":"issues.issue.18","vote":1}

Comments (4)

  1. André Palma

    Hi David. This should be fixed now.

    It is possible to unset the vote by making a DELETE request to the vote endpoint.

    DELETE /v1/likes/<content_id>/vote_up/

  2. David Marrs reporter
    • changed status to open

    Ok, cool DELETE sounds like what I need. Voting up and down seems to work ok, it's just that the user_vote properties in the result of /v1/issues/ still appear to be null. Can you take a look at that when you get a chance.

    Thanks

  3. David Marrs reporter

    Apologies, my fault, I realised during the week that we weren't sending the "Authorization" header with the bearer token when requesting the stances inside the map bounds. So I can now get the user_vote, yay!

    Unfortunately, I've found another problem, which might be a server side issue, or it might just be my misunderstanding how to use the API.

    I can upvote an issue ok, with a POST to, for example, http://api-dev.udemi.org/v1/likes/issues.issue.9/vote_up/

    But I can't then change my mind and downvote with a POST to http://api-dev.udemi.org/v1/likes/issues.issue.9/vote_down/

    However, I can unset the upvote ok, with a DELETE to http://api-dev.udemi.org/v1/likes/issues.issue.9/vote_up/

    But I can't then upvote again, and I still can't downvote the issue.

    And vice versa, I can downvote an issue and then unset that downvote, but can't upvote it, or change my mind and downvote again.

    Hopefully I've explained that ok: am I using the API wrong, or is this a bug?

    Thanks,

    David

  4. Log in to comment