0

I am sending records from WEBApi to the controller. However, I am unable to more than one record to the controller. The parameter "PDFData" shows two records when I hover over it. But when I hover over ticketData parameter, I see only one record.

How do I send more than one records?

WebAPI:

export function buildTicketPDF(PDFData): JQueryXHR {
    return $.ajax({
        url: myApp.utils.getAppUrl() + "/api/BuildTicketPDF",
        type: "POST",
        data: JSON.stringify({ PDFData: PDFData }),
        contentType: "application/json",
    });
}

Controller:

[HttpPost]
public List<PoDataTable> BuildTicketPDF(JObject ticketData)
{
    return boASNTool.BuildTicketPDF(ticketData);
}
venerik
  • 5,766
  • 2
  • 33
  • 43
user990423
  • 1,397
  • 2
  • 12
  • 32
  • Replace `type:"POST"` by `method:"POST"`. But I don't think that `JObject` can be dynamically created from request. – Kalten Mar 19 '16 at 18:19
  • Did you try: `contentType:"application/json"` with JSON request. Have a look [How to pass json POST data to Web API method as object](http://stackoverflow.com/questions/20226169/how-to-pass-json-post-data-to-web-api-method-as-object) –  Mar 19 '16 at 18:30
  • @rajeshmag I already have 'contentType:"application/json"' in my code – user990423 Mar 19 '16 at 18:31
  • Can you add an example in JSON of `PDFData` containing multiple records? – venerik Mar 23 '16 at 09:26

1 Answers1

0

Try this:

data: JSON.stringify({ ticketData: PDFData }),