共用方式為


取代使用者

若要取代整個使用者資源,請在特定使用者資源上執行 PUT 作業。 唯一可取代的屬性是使用者識別碼。 這項取代作業不會影響使用者的權限。

要求

方法 要求 URI Description
PUT HTTPs://{databaseaccount}.documents.azure.com/dbs/{db-id}/users/{user-name} {databaseaccount} 是您訂用帳戶下建立的 Azure Cosmos DB 帳戶名稱。 {db-id} 值是使用者所產生資料庫的名稱/識別碼,而不是系統產生的識別碼 (rid) 。 {user-name} 值是要取代的使用者名稱。

標題

如需所有 Cosmos DB 要求所使用的標頭,請參閱 常見的 Azure Cosmos DB REST 要求標頭

主體

屬性 必要 類型 描述
id 必要 String 提供使用者的新唯一名稱。
{  
    "id": "another_user"  
}  

回應

標題

如需所有 Cosmos DB 回應所傳回的標頭,請參閱 常見的 Azure Cosmos DB REST 回應標頭

狀態碼

下表列出此作業所傳回的常見狀態碼。 如需狀態碼的完整清單,請參閱 HTTP 狀態碼

HTTP 狀態碼 Description
200 確定 取代作業成功。
400 不正確的要求 JSON 內文無效。 檢查是否缺少大括號或引號。
404 找不到 要取代的使用者不再是資源,也就是使用者已刪除。
409 衝突 現有使用者已取得提供給使用者的識別碼。

主體

屬性 Description
_擺脫 這是 系統產生的屬性。 資源識別碼 (_rid) 是資源模型上每個資源堆疊也是階層式的唯一識別碼。 供內部進行放置和導覽使用者資源時使用。
_Ts 這是系統產生的屬性。 代表資源的上次更新時間戳記。 值為時間戳記。
_自我 這是系統產生的屬性。 代表資源的唯一可定址 URI。
_Etag 會產生新的資源 etag
_許可權 這是系統產生的屬性,表示許可權資源的可定址路徑。
{  
    "id": "another_user",  
    "_rid": "Sl8fAFEKCQA=",  
    "_ts": 1449604250,  
    "_self": "dbs\/Sl8fAA==\/users\/Sl8fAFEKCQA=\/",  
    "_etag": "\"00000c00-0000-0000-0000-5667349a0000\"",  
    "_permissions": "permissions\/"  
}  

範例

PUT https://contosomarketing.documents.azure.com/dbs/volcanodb/users/a_user HTTP/1.1  
x-ms-date: Tue, 08 Dec 2015 19:50:50 GMT  
authorization: type%3dmaster%26ver%3d1.0%26sig%3d%2by3RxtfXTgRnAMx2zwCmMFx%2bbKetAvuaGmVYeS1psjE%3d  
Cache-Control: no-cache  
User-Agent: contoso/1.0  
x-ms-version: 2015-08-06  
Accept: application/json  
Host: contosomarketing.documents.azure.com  
Content-Length: 148  
Expect: 100-continue  
Connection: Keep-Alive  
  
{  
    "id": "another_user",  
}  
  
HTTP/1.1 200 Ok  
Cache-Control: no-store, no-cache  
Pragma: no-cache  
Content-Type: application/json  
Content-Location: https://contosomarketing.documents.azure.com/dbs/volcanodb/users/a_user  
Server: Microsoft-HTTPAPI/2.0  
Strict-Transport-Security: max-age=31536000  
x-ms-last-state-change-utc: Sun, 29 Nov 2015 02:25:35.212 GMT  
etag: "00000c00-0000-0000-0000-5667349a0000"  
x-ms-resource-quota: users=500000;  
x-ms-resource-usage: users=2;  
x-ms-schemaversion: 1.1  
x-ms-alt-content-path: dbs/volcanodb  
x-ms-content-path: Sl8fAA==  
x-ms-quorum-acked-lsn: 862  
x-ms-session-token: 863  
x-ms-current-write-quorum: 3  
x-ms-current-replica-set-size: 4  
x-ms-request-charge: 9.9  
x-ms-serviceversion: version=1.5.57.3  
x-ms-activity-id: 8089fc55-a82c-432f-83d2-6a9ad712addd  
x-ms-gatewayversion: version=1.5.57.3  
Date: Tue, 08 Dec 2015 19:50:51 GMT  
Content-Length: 189  
  
{  
    "id": "another_user",  
    "_rid": "Sl8fAFEKCQA=",  
    "_ts": 1449604250,  
    "_self": "dbs\/Sl8fAA==\/users\/Sl8fAFEKCQA=\/",  
    "_etag": "\"00000c00-0000-0000-0000-5667349a0000\"",  
    "_permissions": "permissions\/"  
}  
  

另請參閱