SharePoint List and Hyperlink field with Microsoft Graph results in "bad request
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- csharp
调研方向
The report includes a C# request that posts list item fields to the Microsoft Graph endpoint /sites/{siteId}/lists/{listId}/items, and says the request fails when linkPDF is included. Start by checking the documented Graph format for setting SharePoint hyperlink fields and compare it with the posted Url and Description object. Done means identifying whether the payload or SDK request handling causes the 400 and documenting a working approach.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
I'm trying to add a record to a SharePoint List with a Hyperlink field with Microsoft Graph but I get result "bad request" json payload is {
"fields": {
"Title": "TEST",
"linkPDF": {
"Url": "https://www.microsoft.com",
"Description": "Microsoft"
}
}
}
Code is:
var fields = new JObject
{
["Title"] = entry.Title,
["Maschine"] = entry.Maschine,
["Location"] = entry.Location,
["DocumentNr"] = Convert.ToString(entry.DocumentNr),
["DocumentType"] = entry.Documenttype,
["UploadTarget"] = entry.UploadTarget,
["Message"] = entry.Message,
["TargeteMail"] = entry.TargeteMail,
["PDF"] = entry.PDF
};
if (!string.IsNullOrWhiteSpace(entry.linkPDF))
{
//fields["linkPDF"] = new JObject
//{
// ["Url"] = entry.linkPDF,
// ["Description"] = string.IsNullOrWhiteSpace(entry.PDF) ? entry.linkPDF : entry.PDF
//};
fields["linkPDF"] = new JObject
{
["Url"] = "https://www.microsoft.com",
["Description"] = "Microsoft"
};
}
string json = new JObject { ["fields"] = fields }.ToString();
Globals.CWC($"json={json}", ConsoleColor.Yellow); // zum Prüfen
var request = new RequestInformation
{
HttpMethod = Method.POST,
URI = new Uri($"https://graph.microsoft.com/v1.0/sites/{_siteId}/lists/{_listId}/items")
};
request.SetStreamContent(new MemoryStream(Encoding.UTF8.GetBytes(json)), "application/json");
var errorMapping = new Dictionary<string, ParsableFactory>
{
{ "4XX", ODataError.CreateFromDiscriminatorValue },
{ "5XX", ODataError.CreateFromDiscriminatorValue }
};
try
{
await _graphClient.RequestAdapter.SendAsync(request, ListItem.CreateFromDiscriminatorValue);
}
catch (Microsoft.Graph.Models.ODataErrors.ODataError ex)
Expected behavior
normal entry in the SharePoint list with a hyperlink field (without the hyperlink field everything went fine)
How to reproduce
var fields = new JObject
{
["Title"] = entry.Title,
["Maschine"] = entry.Maschine,
["Location"] = entry.Location,
["DocumentNr"] = Convert.ToString(entry.DocumentNr),
["DocumentType"] = entry.Documenttype,
["UploadTarget"] = entry.UploadTarget,
["Message"] = entry.Message,
["TargeteMail"] = entry.TargeteMail,
["PDF"] = entry.PDF
};
if (!string.IsNullOrWhiteSpace(entry.linkPDF))
{
//fields["linkPDF"] = new JObject
//{
// ["Url"] = entry.linkPDF,
// ["Description"] = string.IsNullOrWhiteSpace(entry.PDF) ? entry.linkPDF : entry.PDF
//};
fields["linkPDF"] = new JObject
{
["Url"] = "https://www.microsoft.com",
["Description"] = "Microsoft"
};
}
string json = new JObject { ["fields"] = fields }.ToString();
Globals.CWC($"json={json}", ConsoleColor.Yellow); // zum Prüfen
var request = new RequestInformation
{
HttpMethod = Method.POST,
URI = new Uri($"https://graph.microsoft.com/v1.0/sites/{_siteId}/lists/{_listId}/items")
};
request.SetStreamContent(new MemoryStream(Encoding.UTF8.GetBytes(json)), "application/json");
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
{
{ "4XX", ODataError.CreateFromDiscriminatorValue },
{ "5XX", ODataError.CreateFromDiscriminatorValue }
};
try
{
await _graphClient.RequestAdapter.SendAsync(request, ListItem.CreateFromDiscriminatorValue);
}
catch (Microsoft.Graph.Models.ODataErrors.ODataError ex)
SDK Version
Graph 6.10 and Kiota 2.1.6
Latest version known to work for scenario above?
never had a running solution
Known Workarounds
no
Debug output
Click to expand log
``` Level 0 Type: System.AggregateException Message: Mindestens ein Fehler ist aufgetreten. StackTrace: bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) bei System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) bei System.Threading.Tasks.Task.Wait() bei e_invoicing.EInvoicingApp.Run(String[] args) in C:\VM\Kairo\e-invoicing\e-invoicing\EInvoicingApp.cs:Zeile 172. Level 1 Type: Microsoft.Kiota.Abstractions.ApiException Message: The server returned an unexpected status code and no error factory is registered for this code: 400 StackTrace: bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__32.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() bei e_invoicing.SharePointLogger.d__4.MoveNext() in C:\VM\Kairo\e-invoicing\e-invoicing\SharepointLogger.cs:Zeile 101. Assertion failed: System.AggregateException: Mindestens ein Fehler ist aufgetreten. ---> Microsoft.Kiota.Abstractions.ApiException: The server returned an unexpected status code and no error factory is registered for this code: 400 bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__32.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() bei e_invoicing.SharePointLogger.d__4.MoveNext() in C:\VM\Kairo\e-invoicing\e-invoicing\SharepointLogger.cs:Zeile 101. --- Ende der internen Ausnahmestapelüberwachung --- bei System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) bei System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) bei System.Threading.Tasks.Task.Wait() bei e_invoicing.EInvoicingApp.Run(String[] args) in C:\VM\Kairo\e-invoicing\e-invoicing\EInvoicingApp.cs:Zeile 191. ---> (Interne Ausnahme #0) Microsoft.Kiota.Abstractions.ApiException: The server returned an unexpected status code and no error factory is registered for this code: 400 bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__32.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei Microsoft.Kiota.Http.HttpClientLibrary.HttpClientRequestAdapter.d__24`1.MoveNext() --- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde --- bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() bei e_invoicing.SharePointLogger.d__4.MoveNext() in C:\VM\Kairo\e-invoicing\e-invoicing\SharepointLogger.cs:Zeile 101.<---Configuration
Windows 11, newest release
x64
Other information
I've tried for 5 days now all different type of hyperlink within a sharepoint list. It works fine by entering the Hyperlink by hand, but I've never succeeded using c#
- 主要语言
- C#
- 星标
- 796
- 派生
- 267
- 平均合并
- 1 天 4 小时
- 30 天内合并 PR
- 5
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoftgraph/msgraph-sdk-dotnet 的其他 Issue
-
status:waiting-for-triage type:bug
难度 1/5 1 小时以内 新手友好度 84/100
microsoftgraph/msgraph-sdk-dotnet#3194 ·
维护者通常 1 天内回复
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 68/100
microsoftgraph/msgraph-sdk-dotnet#3170 ·
维护者通常 1 天内回复
-
status:waiting-for-triage type:bug
难度 2/5 1-3 小时 新手友好度 72/100
microsoftgraph/msgraph-sdk-dotnet#3165 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
Doc Issue - `AddAsync` instead of `PostAsync`可能已有人在做 @hardikkaurani 于 29 天前认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
microsoftgraph/msgraph-sdk-dotnet#3159 ·
维护者通常 1 天内回复
-
Bug: metadata
难度 2/5 1-3 小时 新手友好度 68/100
microsoftgraph/msgraph-sdk-dotnet#3004 · 1 条评论 ·
维护者通常 1 天内回复
查看 microsoftgraph/msgraph-sdk-dotnet 的全部 Issue
相似的 Issue
-
a-corriger bug
难度 2/5 1-3 小时 新手友好度 86/100
christian-raj/S-Aloha#340 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
microsoft/microsoft-ui-reactor#1626 ·
维护者通常 1 天内回复
-
Triage:Untriaged Type:Bug
难度 2/5 1-3 小时 新手友好度 79/100
-
area: opcua type: bug
难度 2/5 1-3 小时 新手友好度 85/100
RicoSuter/Namotion.Interceptor#1020 ·
维护者通常 1 天内回复
-
area-messaging-patterns bug p1-recommended
难度 2/5 1-3 小时 新手友好度 77/100
维护者通常 1 天内回复