C# 如何使用Microsoft.Graph将文件附加到Sharepoint中的项目
Microsoft.Graph Sharepoint api允许使用修补程序请求更新列表项。但是如何生成正确的请求呢C# 如何使用Microsoft.Graph将文件附加到Sharepoint中的项目,c#,sharepoint,microsoft-graph-api,C#,Sharepoint,Microsoft Graph Api,Microsoft.Graph Sharepoint api允许使用修补程序请求更新列表项。但是如何生成正确的请求呢 using (HttpClient pacthClient = new HttpClient()) { var mediaType = new MediaTypeWithQualityHeaderValue("application/json"); pacthClient.DefaultRequestHeaders.Accept.A
using (HttpClient pacthClient = new HttpClient())
{
var mediaType = new MediaTypeWithQualityHeaderValue("application/json");
pacthClient.DefaultRequestHeaders.Accept.Add(mediaType);
pacthClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken);
using (HttpRequestMessage requestMessage = new HttpRequestMessage(new HttpMethod("PATCH"), $"{uri}/{id}"))
{
requestMessage.Content = byteArrayContent ???
using (HttpResponseMessage responseMessage = await pacthClient.SendAsync(requestMessage))
{
}
}
}
看起来像是这个的复制品:
string addItemJsonString = "{\"name\":\"Test Visit\"}";
string requestUrl = "https://graph.microsoft.com/v1.0/sites/{siteID}/lists/{listID}/items/{itemID}/fields";
HttpClient client = new HttpClient();
HttpRequestMessage message = new HttpRequestMessage(new HttpMethod("PATCH"), requestUrl);
message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
//set the request body
message.Content = new StringContent(addItemJsonString);
HttpResponseMessage response = await client.SendAsync(message);
if (response.IsSuccessStatusCode)
{
responseString = await response.Content.ReadAsStringAsync();
}
else
responseString = "Error in response";