ASP.Net Pre-Built Endpoints
JobFlow's Web package includes several pre-build API endpoints for ASP.Net. In order to enable these endpoints, two steps are required in your Startup class.
More endpoints than the ones provided may be added in the future, including a pre-built de-batching endpoint.
Add Controllers
First, the controller classes needed to be added to the service collection. Also note that JobFlow currently relies on Newtonsoft's Json implementation. The following code should be added/modified in the Startup.ConfigureServices method (or equivalent):
services.AddControllers()
.AddNewtonsoftJson()
.AddJobFlowControllers();
This adds the following controllers and methods:
WorkItemControllerNew- Create a new WorkItem without attachmentsNewWithAttachments- Expects a mutli-part MIME message with a 'workItem' element and any additional attachment file objects
Add Controller Routes
To add appropriate routes to the controllers, the following code can be added/modified in the Startup.Configure method or equivalent:
app.UseEndpoints(endpoints =>
{
endpoints.MapControllers();
endpoints.AddDefaultWorkItemRoutes();
});
Each method can take a route prefix as a parameter. The prefix defaults to /api.
This adds the following routes:
AddDefaultWorkItemRoutesworkitem(POST) - routes to theWorkItemController.Newmethod- The body of the message is the JSON work item document
workitem/withAttachemnts(POST) - routes to theWorkItemController.NewWithAttachmentsmethod- MIME-encoded multipart message with a 'workItem' piece and any additional attachment files