How to get merge proposal vote details via WS API?

Asked by Chris Hillery

I want to get vote information for a merge proposal, most specifically the set of users that have been requested to review.

I know that this information is available via the votes_collection_link information from a branch_merge_proposal. For instance, for one merge proposal I'm looking at, the votes_collection_link is

https://api.launchpad.net/1.0/~zorba-coders/zorba/windows-hashmap-workaround/+merge/131716/votes

However, the response from that WS call is

{"total_size": 2, "start": 0, "entries": [], "resource_type_link" : "https://api.launchpad.net/1.0/#code_review_vote_reference-page-resource"}

As you see the entries array is empty, even though the total_size is 2. So I cannot tell how I am supposed to get the actual data.

If I use python launchpadlib, I can get the votes as I would expect and they are populated, but I need to do this from Javascript using simple WS calls. (I have been trying to figure out how I can sniff the WS calls that launchpadlib actually makes, but since it's https: so far I have been unsuccessful.)

Question information

Language:
English Edit question
Status:
Answered
For:
Launchpad itself Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
William Grant (wgrant) said :
#1

Some types of objects aren't currently available unless you're authenticated. The account's privileges don't matter for those votes, just that you're authenticated as any account at all. However, why are you trying to use the Launchpad API from JavaScript? Launchpad doesn't support JSONP, CORS, or other cross-site request technologies, so you're going to be somewhat limited in terms of the sort of requests you can make from a browser.

You can set httplib2.debuglevel (before using launchpadlib) to see the request details:

$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from launchpadlib.launchpad import Launchpad
>>> import httplib2
>>> httplib2.debuglevel = 1
>>> lp = Launchpad.login_with('fewfwfw', 'production', version='devel')
connect: (api.launchpad.net, 443)
send: 'GET /devel/ HTTP/1.1\r\nHost: api.launchpad.net\r\nAuthorization: OAuth realm="OAuth", [...]

Revision history for this message
Chris Hillery (ceejatec) said :
#2

Ok, thanks; that's interesting. Why would this particular case require authentication? I can go to the corresponding webpage (https://code.launchpad.net/~zorba-coders/zorba/windows-hashmap-workaround/+merge/131716 ) and see all that information without providing any kind of credentials.

Would it be worth filing a bug requesting that the requirement for authentication be removed for this case?

As to why I'm using Javascript: Because my use case is loading Launchpad information into a Google Docs spreadsheet. The language for programming Google Docs is Javascript. I already have a fairly extensive spreadsheet managing our Launchpad bug information, which is populated via Javascript scripts that just hit Launchpad URLs and consume the JSON output. I wanted to extend this management spreadsheet to track outstanding merge proposals as well, when I hit this wall.

I'm not sure how to proceed here; I don't know how to provide credential information when I'm just hitting a WS URL. I'll keep investigating. Thanks for the information about debugging with httplib2; that may help me answer the question.

Can you help with this problem?

Provide an answer of your own, or ask Chris Hillery for more information if necessary.

To post a message you must log in.