C# 无法创建外部项
正在尝试使用创建外部项C# 无法创建外部项,c#,microsoft-graph-api,C#,Microsoft Graph Api,正在尝试使用创建外部项 await graphClient.Connections[connectionId].Items[item.Id].Request().PutAsync(item); 通过发送以下邮件: { "properties": { "ticketTitle": "title of the item", "priority": "high",
await graphClient.Connections[connectionId].Items[item.Id].Request().PutAsync(item);
通过发送以下邮件:
{
"properties": {
"ticketTitle": "title of the item",
"priority": "high",
"assignee": "someone@somewhere.com",
"additionalData": null,
"@odata.type": null
},
"acl": [
{
"accessType": 1,
"identitySource": "External",
"type": 1,
"value": "SomeUser",
"additionalData": null,
"@odata.type": "microsoft.graph.acl"
}
],
"content": {
"type": 1,
"value": "Some value",
"additionalData": null,
"@odata.type": "microsoft.graph.externalItemContent"
},
"id": "ABCD12345",
"@odata.type": "microsoft.graph.externalItem",
"additionalData": null
}
但我得到了以下回应:
Code: UnknownError
Inner error:
AdditionalData:
date: 2021-03-24T22:31:31
request-id: fc55be4e-c84d-4376-8305-d0e33f2729a0
client-request-id: fc55be4e-c84d-4376-8305-d0e33f2729a0
ClientRequestId: fc55be4e-c84d-4376-8305-d0e33f2729a0
我做错了什么?我试着在属性中不发送额外的数据或ODataType,但同样的错误是这是Graph SDK beta版中的一个bug。血淋淋的细节在-但本质上我监视网络流量,并注意到没有对Graph API的PUT调用。Graph SDK beta使用的请求url在“beta”和“connections”之间缺少“external”,因此使用“beta/external/connections”而不是“beta/external/connections”
啊啊啊。(我想这就是为什么它被称为beta)。转储了graph客户端正在使用的URL。它缺少“external”(在测试版之后和连接之前):外部项的创建在PowerShell中工作,因为我使用的是完整的URL。这是Graph Client SDK中的一个错误吗?我不知道如何修复Graph SDK测试版中的路径-所以现在使用了一个hack。因此,对于那些被阻止的用户,您可以更改使用C#反射来更新只读RequestUrl属性<代码>var externalItemRequest=graphClient.Connections[connectionId].Items[item.Id].Request();var requestUrl=externalItemRequest.requestUrl;externalItemRequest.GetType().GetProperty(“RequestUrl”).SetValue(externalItemRequest,RequestUrl.Replace(“连接”,“外部/连接”))代码>这实际上是一个文档错误。它必须是
var externalItemRequest=graphClient.External.Connections[connectionId].Items[itemId].Request()
。文档中的示例代码丢失了,我发布了一个PR,它也被接受了。