0

When creating a work item with the following arguments, we get what appears to be an internal error from 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()"
    }
  }
}

This happens with the following JSON passed to Forge. (Some values have been changed from actual)

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

I've tried any number of variations on this code. I've added other fields and included default values... But nothing gets passed this.

Mike
  • 8,853
  • 3
  • 35
  • 44
  • Can you check whether your Activity really have an output parameter called "GeneratedDrawing.dwg"? This name looks like a LocalFileName of the corresponding Activity parameter. I suspect the output parameter is named something like "Results" and your workitem's output argument has to match the parameter by parameter name. – Qun Lu Mar 04 '19 at 23:01
  • That's a good catch. I changed the Name OutputArgument to match "Results". Results was the right name in the sample code. However, I still get the same error. – Mike Mar 05 '19 at 15:00
  • As a sanity check, when I follow the tutorial for something simple like converting a DWG to a PDF, submitting the activity gives me a 504 Gateway Timeout. Is it possible there is something wrong with this Forge API Account? – Mike Mar 05 '19 at 15:02
  • This is caused by the `ModelState` being invalid (your request body fails validity against against the arguments scheme of the target activity, and the null pointer error in the response is actually bad coding practice on our part but had nothing to do with the cause of the issue). Are you sure all the names and values match for the inputs and outputs? – Bryan Huang Mar 12 '19 at 06:04

1 Answers1

0

The first problem I see is the trailing commas you have. This is not valid json. You shouldn't have a comma after "Generic" in InputArguments["HostDwg"] and OutputArguments["GeneratedDrawing.dwg"].

Albert Szilvasy
  • 461
  • 3
  • 5
  • Thanks for the input! I had actually deleted some fields that were included in the last request. I had a line `"Authentication": null` after both `StorageProviders`. I've made sure to manually verify that requests are valid json via https://jsonlint.com. I.e., if you remove the comma, I still get the same error. – Mike Mar 04 '19 at 21:51