gpt4 book ai didi

javascript - PATCH指令返回HTTP 500代码,消息为 ""消息“: "Object reference not set to an instance of an object.""

转载 作者:行者123 更新时间:2023-12-03 01:11:04 25 4
gpt4 key购买 nike

我正在尝试更新 Dynamics CRM 365 中联系人实体的一些属性。

我正在使用 Web API 并将我的更新发送至:

http://<URI>/api/data/v8.0/contacts(a29d23c0-f75a-e611-80c4-0050568deb29)

例如:

Headers :

content-type: application/json
accept: application/json
OData-MaxVersion: 4.0
OData-Version: 4.0
Authorization: 'the token'

Body:
{
"address1_city": "new city",
"address1_country": "new country",
}

但是,当我执行此请求时,我收到:

{"error":{"code":"0x0","message":"Object reference not set to an instance of an object.","innererror":{"message":"Object reference not set to an instance of an object.","type":"System.NullReferenceException","stacktrace":" at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.ValidatePatchInputProperties(EdmEntityObject entityDelta, CrmODataExecutionContext crmODataExecutionContext)\r\n at Microsoft.Crm.Extensibility.OData.EntityController.PatchEntityImplementation(String& entityName, String key, EdmEntityObject entityDelta)\r\n at Microsoft.PowerApps.CoreFramework.ActivityLoggerExtensions.Execute[TResult](ILogger logger, EventId eventId, ActivityType activityType, Func`1 func, IEnumerable`1 additionalCustomProperties)\r\n at Microsoft.Xrm.Telemetry.XrmTelemetryExtensions.Execute[TResult](ILogger logger, XrmTelemetryActivityType activityType, Func`1 func)\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"}}}

最佳答案

这是 powershell 中的工作示例。我的 header 有点不同,我在 v8.2 上使用端点:

$headers = @{
"Content-Type"="application/json; charset=utf-8";
"OData-MaxVersion"="4.0";
"OData-Version"="4.0";
};

$body = @{
"address1_city"="new city";
"address1_country"="new country";
};

$json = ConvertTo-Json $body;

$result = Invoke-WebRequest -Uri "$serverurl/api/data/v8.2/contacts(66B652BF-06AB-E811-80EE-005056935BD6)" -Method PATCH -Headers $headers -Body $json -UseDefaultCredentials;

Write-Host $result.StatusCode;

关于javascript - PATCH指令返回HTTP 500代码,消息为 ""消息“: "Object reference not set to an instance of an object."",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52205319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com