Using ASP.NET WebAPI v2, how can I get PDF POST data in the WebAPI method?

The idea is that there will be an external object (SharePoint) that will call my WebAPI and transfer to the PDF file, as well as some additional metadata about this PDF file. I went in cycles on how to create a signature of the Web API method. Here is what I still have:

public class IssueController : ApiController
{
    private TestEntities db = new TestEntities(HelperClasses.ConnectionStringHelper.GetConnectionString());

    [HttpPost]
    public HttpResponseMessage SavePdf(Article a)
    {
        // save the PDF to a file share & metadata to the SQL database
    }
}

My desire would be to do something like:

public class IssueController : ApiController
{
    private TestEntities db = new TestEntities(HelperClasses.ConnectionStringHelper.GetConnectionString());

    [HttpPost]
    public HttpResponseMessage SavePdf(Article a, HttpPostedFileBase file)
    {
        // save the PDF to a file share & metadata to the SQL database
    }
}

But I'm not sure if using WebAPI exactly do this.

QUESTION . How to define a WebAPI method capable of receiving PDF data and some additional metadata as a request POSTfrom an external object?

+3
source share

All Articles