3

The idea is that there will be an external entity (SharePoint) that will call my WebAPI and pass in a PDF file as well as some extra, metadata information about that PDF file. I'm stuck on how to construct the signature of the Web API method. Here's what I have so far:

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 inclination 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 with WebAPI how to exactly do this.

QUESTION: How would I define a WebAPI method capable of accepting PDF data & some extra metadata as a POST request from an external entity?

Mike Marks
  • 10,017
  • 17
  • 69
  • 128

1 Answers1

0

if you want to pass complex object , i suggest you to use JObject.

JObject: http://blog.travisgosselin.com/web-api-signatures-with-multiple-complex-parameters/

PostFiles: http://www.asp.net/web-api/overview/working-with-http/sending-html-form-data,-part-2

natnael88
  • 1,128
  • 10
  • 22