tôi cần phải gọi REST của thiết bị đầu cuối nàyLàm thế nào để gửi đúng yêu cầu PATCH
PATCH https://graph.windows.net/contoso.onmicrosoft.com/users/[email protected]?api-version=1.5 HTTP/1.1
{
"<extensionPropertyName>": <value>
}
Xin xem tài liệu ở đây: https://msdn.microsoft.com/en-us/library/azure/dn720459.aspx
Tôi có đoạn code sau để thiết lập giá trị của một tài sản cho một người sử dụng:
public async Task<ActionResult> AddExtensionPropertyValueToUser()
{
Uri serviceRoot = new Uri(azureAdGraphApiEndPoint);
var token = await GetAppTokenAsync();
string requestUrl = "https://graph.windows.net/mysaasapp.onmicrosoft.com/users/[email protected]?api-version=1.5";
HttpClient hc = new HttpClient();
hc.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, requestUrl)
{
Content = new StringContent("{ \"extension_33e037a7b1aa42ab96936c22d01ca338_Compania\": \"Empresa1\" }", Encoding.UTF8, "application/json")
};
HttpResponseMessage hrm = await hc.GetAsync(new Uri(requestUrl));
if (hrm.IsSuccessStatusCode)
{
string jsonresult = await hrm.Content.ReadAsStringAsync();
return View("TestRestCall", new SuccessViewModel
{
Name = "The Title",
Message = "The message",
JSON = jsonresult.ToJson()
});
}
else
{
return View();
}
}
Tuy nhiên thay vì respongint với 204 thuộc tính người dùng, vì vậy tôi đoán có điều gì đó không ổn với phần còn lại của tôi GỌI
http://screencast.com/t/LmoNswKIf2
Bạn đề cập đến bạn không nhận được 204, nhưng thuộc tính tiện ích mở rộng đã được viết ? –