net core api newtonsoft.json 检测到类型为 'Microsoft.Graph.GraphServiceClient' 的 属性 'Client' 的自引用循环。路径 'Invitations'
net core api newtonsoft.json Self referencing loop detected for property 'Client' with type 'Microsoft.Graph.GraphServiceClient'. Path 'Invitations'
我在会话中存储GraphServiceClient(因为我需要在其他请求中使用它):
HttpContext.Session.SetObject("graphClient", _graphServiceClient);
GraphServiceClient是一个Object,所以我扩展了Session:
public static class SessionExtensions
{
public static void SetObject(this ISession session, string key, object value)
{
session.SetString(key, JsonConvert.SerializeObject(value));
}
public static T GetObject<T>(this ISession session, string key)
{
var value = session.GetString(key);
return value == null ? default(T) : JsonConvert.DeserializeObject<T>(value);
}
}
尝试 Post 请求时,我收到以下 401 状态错误
"Self referencing loop detected for property 'Client' with type
'Microsoft.Graph.GraphServiceClient'. Path 'Invitations'."
正如 Marc LaFleur 所建议的,我通过存储令牌解决了这个问题
我在会话中存储GraphServiceClient(因为我需要在其他请求中使用它):
HttpContext.Session.SetObject("graphClient", _graphServiceClient);
GraphServiceClient是一个Object,所以我扩展了Session:
public static class SessionExtensions
{
public static void SetObject(this ISession session, string key, object value)
{
session.SetString(key, JsonConvert.SerializeObject(value));
}
public static T GetObject<T>(this ISession session, string key)
{
var value = session.GetString(key);
return value == null ? default(T) : JsonConvert.DeserializeObject<T>(value);
}
}
尝试 Post 请求时,我收到以下 401 状态错误
"Self referencing loop detected for property 'Client' with type 'Microsoft.Graph.GraphServiceClient'. Path 'Invitations'."
正如 Marc LaFleur 所建议的,我通过存储令牌解决了这个问题