SharePoint List and Hyperlink field with Microsoft Graph results in "bad request
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- csharp
- Área
- backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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#
- Lenguaje dominante
- C#
- Estrellas
- 796
- Forks
- 267
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 5
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoftgraph/msgraph-sdk-dotnet
-
status:waiting-for-triage type:bug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 84/100
microsoftgraph/msgraph-sdk-dotnet#3194 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoftgraph/msgraph-sdk-dotnet#3170 ·
Los mantenedores suelen responder en 1 día
-
status:waiting-for-triage type:bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
microsoftgraph/msgraph-sdk-dotnet#3165 · 2 comentarios · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Doc Issue - `AddAsync` instead of `PostAsync`Posiblemente ocupada @hardikkaurani la tomó hace 29 días. Abierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
microsoftgraph/msgraph-sdk-dotnet#3159 ·
Los mantenedores suelen responder en 1 día
-
Bug: metadata
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
microsoftgraph/msgraph-sdk-dotnet#3004 · 1 comentario ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoftgraph/msgraph-sdk-dotnet
Issues similares
-
a-corriger bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
christian-raj/S-Aloha#340 ·
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/microsoft-ui-reactor#1626 ·
Los mantenedores suelen responder en 1 día
-
Triage:Untriaged Type:Bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 79/100
-
area: opcua type: bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
RicoSuter/Namotion.Interceptor#1020 ·
Los mantenedores suelen responder en 1 día
-
area-messaging-patterns bug p1-recommended
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día