2013-05-15 47 views
0

如何獲得用戶所在團隊(組織)的JSON對象?使用Bitbucket API獲取用戶所在的團隊

我正在尋找在documentationBitbucket REST API Console

基本上我需要爲orgs.getFromUserfunction from Github API,我傳遞用戶名認證後的記者。

+0

您鏈接到通用Atlassian的文件,但它是安全的,假設你已經通過特定[REST API文檔]看了(https://confluence.atlassian.com/display/BITBUCKET/Using+the+Bitbucket+ REST的API +#UsingtheBitbucketRESTAPIs-SupportedEndpointsandtheirResources)? –

回答

1

使用 「用戶端點」 爲API 1.0

https://confluence.atlassian.com/display/BITBUCKET/user+Endpoint

您尋找的調用是:https://bitbucket.org/api/1.0/user/privileges

您需要用戶身份驗證調用這個:

curl -u "USER_NAME:USER_PASSWORD" https://bitbucket.org/api/1.0/user/privileges 

這將返回一個隊列表:

{u'teams': {u'team1': u'admin', u'team2': u'admin'}} 
2

我認爲你正在尋找this endpoint

您提供accountname併爲其身份驗證,並GET /1.0/groups/:accountname/。它將返回文檔頁面上顯示的對象列表。

+0

你是對的。我沒有找到它,因爲在Bitbucket上他們被稱爲「團隊」,在Github「組織」上,我在API「組」中看到了這一點。爲什麼當我輸入[this](https://api.bitbucket.org/1.0/groups)url時收到「Bad request」?如果我去[這裏](https://api.bitbucket.org/1.0/user/repositories/),我可以在auth後看到我的存儲庫。它還會在REST API控制檯中拋出「錯誤的請求」。 –

+0

我不知道爲什麼在訪問'/ groups'而不是'/ user/repositories'時在瀏覽器中拋出一個錯誤的請求。這可能是Atlassian在支持請求中指出的。 –

+0

問題解決後我會接受這個答案。如果您發現有用的信息,請發佈。謝謝。 –

相關問題