ho bisogno di chiamare questo riposo endpointCome inviare correttamente una richiesta PATCH
PATCH https://graph.windows.net/contoso.onmicrosoft.com/users/[email protected]?api-version=1.5 HTTP/1.1
{
"<extensionPropertyName>": <value>
}
Si prega di consultare la documentazione qui: https://msdn.microsoft.com/en-us/library/azure/dn720459.aspx
Ho il seguente codice per impostare il valore di una proprietà per un utente:
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();
}
}
Tuttavia, invece di respongint con 204 (Nessun contenuto), la sua risposta con l'intero proprietà utente, quindi credo che qualcosa non va con il mio riposo CALL
http://screencast.com/t/LmoNswKIf2
Hai detto che non stai ricevendo il 204, ma che l'attributo di estensione era stato scritto ? –