使用带有HTTP客户端的C#的补丁请求 - Microsoft Graph

时间:2018-03-07 13:17:20

标签: c# httpclient microsoft-graph patch

我必须在C#中使用HTTP客户端进行补丁请求。查看Get请求非常简单:

        var httpclient = GetHttpClient(accessToken.Result);
        var response = await 
        httpclient.GetAsync("https://graph.microsoft.com/v1.0/me/messages");
        response.EnsureSuccessStatusCode();
        var content = await response.Content.ReadAsStringAsync();
        JObject o = JObject.Parse(content);

但是对于补丁,我找不到PatchAsync方法,似乎只有POST和PUT。

1 个答案:

答案 0 :(得分:1)

在代码中将GetAsync替换为

var httpclient = GetHttpClient(accessToken.Result);
var response = await client.SendAsync(new HttpRequestMessage(new HttpMethod("PATCH"), "https://graph.microsoft.com/v1.0/me/messages"));
response.EnsureSuccessStatusCode();
var content = await response.Content.ReadAsStringAsync();
JObject o = JObject.Parse(content);