2017-02-13 53 views

回答

0

在發出請求之前,您需要確保關聯的帳戶已經建立,並且您已經獲得了oauth2標記。如果使用ShareFile帳戶登錄並訪問the documentation,則可以使用的oauth2標記將顯示在頁面的頂部。

從那裏你需要構建你的請求。下面是一些細節用星號絕密爲例請求,以保護無辜:

POST /sf/v3/Users HTTP/1.1 
Host: **********.sf-api.com 
Authorization: Bearer ********** 
Content-Type: application/json 
Cache-Control: no-cache 

{"Preferences": {"CanResetPassword": true, "CanViewMySettings": true}, "FirstName": "Billy", "LastName": "Bobby", "Company": "Bobby's World", "Password": "**********", "Email": "**********", "DefaultZone": {"Id": "**********"}} 

這裏是一個示例響應正文:

{ 
"Email": "************", 
"Username": "************", 
"TotalSharedFiles": 0, 
"Id": "************", 
"Contacted": 0, 
"FirstName": "Billy", 
"ReferredBy": "************", 
"IsConfirmed": false, 
"LastName": "Bobby", 
"Company": "Bobby's World", 
"FullNameShort": "B. Bobby", 
"DateCreated": "2017-02-13T22:19:07.92Z", 
"odata.metadata": "https://************.sf-api.com/sf/v3/$metadata#Users/[email protected]", 
"url": "https://************.sf-api.com/sf/v3/Users(************)", 
"Domain": "************", 
"FullName": "Billy Bobby", 
"odata.type": "ShareFile.Api.Models.User", 
"Roles": 
    ["Client", "CanChangePassword", "CanManageMySettings"], 
"Emails": ["************"] 
} 

隨着響應身體會有一些頭根據你的情況,這可能是有用的。特別要注意Set-Cookie頭文件SFAPI_AuthIDSFAPI_SRVNAMEAccording to the documentation這些值可以由您的客戶端保留,並用於緩解ShareFile API服務器上後續API調用的負載。

+0

值得注意的是,如果您從請求中省略Content-Type標頭,您將收到500個響應。這看起來很奇怪,但很容易解決。 –