代码之家  ›  专栏  ›  技术社区  ›  Azoulay Jason

修补程序指令返回HTTP 500代码,其中包含消息“message”:“对象引用未设置为对象的实例”

  •  0
  • Azoulay Jason  · 技术社区  · 7 年前

    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.”,“innerror”:{“message”:“Object reference not set to an instance of an Object.”,“type”:System.NullReferenceException异常“,”stacktrace“:”在Microsoft.Crm.Extensibility可扩展性.OData.CrmODataUtilities.ValidatePatchInputProperties(EdmEntityObject实体增量,CrmODataExecutionContext CrmODataExecutionContext)\r\n位于Microsoft.Crm.Extensibility可扩展性.OData.EntityController.PatchEntityImplementation文件(String&entityName,String key,EdmEntityObject entityDelta)\r\n位于Microsoft.PowerApps.CoreFramework.活动VityLogger扩展。执行[TResult](ILogger记录器,EventId EventId,ActivityType ActivityType,Func`1 Func,IEnumerable`1 additionalCustomProperties)\r\n位于Microsoft.Xrm.遥测.Xr文件mTelemetryExtensions.执行[TResult](ILogger logger,xrmtemetryactivitytype activityType,Func`1 Func)\r\n位于lambda\u方法(闭包,对象,对象[])\r\n位于系统.Web.Http.控制器.反射HttpActionDescriptor.行动执行人。<>c\u DisplayClass10.b\u 9(对象实例,Object[]methodParameters)\r\n位于系统.Web.Http.控制器.反射HttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext,IDictionary`2个参数,CancellationToken CancellationToken)\r\n---来自引发异常的上一个位置的堆栈结束跟踪---\r\nSystem.Runtime.ExceptionServices服务EExceptionDispatchInfo.Throw异常()\r\n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification任务等待者.HandleNonSuccessAndDebuggerNotification(任务)\r\n位于系统.Web.Http.控制器.ApiControllerActionInvoker.d\uu 0.MoveNext()\r\n---从引发异常的上一个位置开始的堆栈结束跟踪---\r\nSystem.Runtime.ExceptionServices服务EExceptionDispatchInfo.Throw异常()\r\n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification任务等待者.HandleNonSuccessAndDebuggerNotification(任务)\r\n位于系统.Web.Http.控制器.ActionFilterResult.d\uu 2.MoveNext()\r\n---从引发异常的上一个位置开始的堆栈结束跟踪---\r\nSystem.Runtime.ExceptionServices服务EExceptionDispatchInfo.Throw异常()\r\n在System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification任务等待者.HandleNonSuccessAndDebuggerNotification(任务)\r\n位于系统.Web.Http.Dispatcher.HttpControllerDispatcher程序.d\uu 1.MoveNext()“}}

    1 回复  |  直到 7 年前
        1
  •  1
  •   Nick    7 年前

    下面是powershell中的一个工作示例。我的头有点不同,我在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;