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?
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.