Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用Microsoft.Graph将文件附加到Sharepoint中的项目_C#_Sharepoint_Microsoft Graph Api - Fatal编程技术网

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

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

Microsoft.Graph Sharepoint api允许使用修补程序请求更新列表项。但是如何生成正确的请求呢

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