问题描述
我有UWP App,当前正在使用Microsoft Graph API.我经常遇到问题.
I have UWP App and currently working with Microsoft Graph API. I am constantly running into issue.
问题是,当我尝试在共享点上创建ListItem时,会引发错误.
The issue is when I tried to create ListItem at sharepoint, it throws an error.
状态代码:400,ReasonPhrase:错误请求"
我的代码如下
string addItemJsonString = "{\"fields\":{\"Title\":\"This is test record\"}}";
string requestUrl = "https://graph.microsoft.com/v1.0/sites/MySharepointSite/lists/Documents/items";
HttpClient client = new HttpClient();
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, requestUrl);
message.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
message.Content = new StringContent(addItemJsonString, Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json; charset=utf-8");
HttpResponseMessage response = await client.SendAsync(message);
我点击了此链接https://developer.microsoft.com/zh-CN/graph/docs/api-reference/v1.0/api/listitem_create#request-body
I followed this link https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/listitem_create#request-body
任何帮助都是有意义的. :)
Any help would be appreciable. :)
谢谢
推荐答案
string requestUrl = "https://graph.microsoft.com/v1.0/sites/{site-id}/lists/{list-id}/items"
您是否在网站和列表的实际指南上更改了{site-id}和{list-id}?
did you change {site-id} and {list-id} on actual guids of your site and list?
这篇关于如何使用Graph API C#创建sharepoint ListItem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!