2017-05-25 42 views
0

如果我有一個ID爲「[email protected]」的Office 365組/微軟團隊,並且我想使用其中一個測試API(如this)查詢它,我需要查詢一個URL,例如https://graph.microsoft.com/beta/groups/{id}/threads。不過,我堅持編碼團隊名稱。 https://graph.microsoft.com/beta/groups/[email protected]/threadshttps://graph.microsoft.com/beta/groups/[email protected]%2Eonmicrosoft%2E/threadshttps://graph.microsoft.com/beta/groups/[email protected]/threadshttps://graph.microsoft.com/beta/groups/"[email protected]"/threads,https://graph.microsoft.com/beta/groups/"[email protected]"/threads所有返回以下錯誤如何編碼Microsoft組和團隊名稱的名稱,以將它們包含在API調用URL中?

"error": { 
    "code": "Request_BadRequest", 
    "message": "Invalid object identifier 'whatever_I_entered'." 

回答

1

據我瞭解,它只是普通的URL編碼。例如在JS中,您可以使用功能encodeURIComponent(str)。如果你想嘗試使用online URL encoder。例如編碼的[email protected]意志版本看起來像testteam%40example.onmicrosoft.com和你的圖形要求將https://graph.microsoft.com/beta/groups/testteam%40example.onmicrosoft.com/threads

編輯:

在你需要使用編號組的請求。例如:Get Group請求可能看起來像...並且組ID是c28c1cc9-e1ab-4c4d-98d1-d8fdf128b60f

https://graph.microsoft.com/v1,0/groups/c28c1cc9-e1ab-4c4d-98d1-d8fdf128b60f?$select=description,allowExternalSenders 
+0

這會產生相同的錯誤。 – stackquestions23

+0

您可以運行請求來檢索可用組的列表嗎? [List Groups](https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/group_list)。你在列表中看到請求的組ID嗎?順便說一下,你需要使用** ID **! –

+0

謝謝,就是這樣!在Office365管理面板中,名稱@電子郵件格式標記爲組ID,但您鏈接到的列表組API會返回正確的值。 – stackquestions23

相關問題