创建工作项失败,并显示“对象引用未设置为对象的实例”。

时间:2019-03-04 19:08:22

标签: autodesk-forge autodesk-designautomation

使用以下参数创建工作项时,我们从伪造中发现了内部错误:

{
  "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
}

我已经尝试了此代码的多种变体。我添加了其他字段并包括默认值...但是什么都没有通过。

1 个答案:

答案 0 :(得分:0)

我看到的第一个问题是尾随逗号。这是无效的json。在InputArguments [“ HostDwg”]和OutputArguments [“ GeneratedDrawing.dwg”]中,“ Generic”之后不应有逗号。