如何使用Microsoft.Graph将文件附加到Sharepoint中的项目

Microsoft.Graph Sharepoint api允许使用PATCH请求更新列表项https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/listitem_update 。 但是如何生成正确的请求?

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";