代码之家  ›  专栏  ›  技术社区  ›  Mike

创建工作项失败,原因是“对象引用未设置为对象的实例”

  •  0
  • Mike  · 技术社区  · 6 年前

    当使用以下参数创建工作项时,我们从forge获得了一个内部错误:

    {
      "error":{
        "code":"","message":"An error has occurred.","innererror":{
          "message":"Object reference not set to an instance of an object.","type":"System.NullReferenceException","stacktrace":"   at PublicApi.ResponseExceptionHelper.Throw(HttpStatusCode status, ModelStateDictionary state) in G:\\Repos\\IO\\src\\PublicAPI\\ResponseExceptionHelper.cs:line 31\r\n   at PublicApi.V2.Controllers.WorkItemsV2Controller.CreateEntity(WorkItem2 workItem) in G:\\Repos\\IO\\src\\PublicAPI\\V2\\Controllers\\WorkItemsV2Controller.cs:line 57\r\n   at PublicApi.V2.Controllers.BaseController`1.Post(TEntity entity) in G:\\Repos\\IO\\src\\PublicAPI\\V2\\Controllers\\BaseV2Controller.cs:line 62\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.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.ApiControllerActionInvoker.<InvokeActionAsyncCore>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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.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.<ExecuteAsync>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.Tracing.Tracers.HttpControllerTracer.<ExecuteAsyncCore>d__5.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.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__18`1.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.<SendAsync>d__1.MoveNext()"
        }
      }
    }
    

    将以下JSON传递给Forge时会发生这种情况。(某些值已从实际值更改)

    {
      "@odata.type": "#ACES.Models.WorkItem",
      "ActivityId": "CustomActivity",
      "Arguments": {
        "InputArguments": [
          {
            "HttpVerb": "GET",
            "Name": "HostDwg",
            "Resource": "https://s3.amazonaws.com/[path-redacted]",
            "ResourceKind": "ZipPackage",
            "StorageProvider": "Generic"
          },
          {
            "HttpVerb": "GET",
            "Name": "Request",
            "Resource": "https://s3.us-east-2.amazonaws.com/[path-redacted]",
            "ResourceKind": "ZipPackage",
            "StorageProvider": "Generic"
          }
        ],
        "OutputArguments": [
          {
            "HttpVerb": "POST",
            "Name": "GeneratedDrawing.dwg",
            "ResourceKind": "ZipPackage",
            "StorageProvider": "Generic"
          }
        ]
      },
      "Id": "",
      "UserID": "",
      "Version": 1
    }
    

    我在这段代码上尝试了很多变体。我已经添加了其他字段并包含了默认值。。。但是没有什么能通过这个。

    0 回复  |  直到 6 年前
        1
  •  0
  •   Albert Szilvasy    6 年前