0

I am trying to send an array of items, whether that's a model[] of varying types or a string[]. From what I've looked at so far it doesn't seem possible, although we send arrays of models to the API controllers already using AJAX calls, this however needs to be sent from an App.

Currently I am sending one at a time to the server, I have tried using the [HtmlPost] tag as well as sending things via List, item[] and serialised as a string object (winds up too large easily).

//App Code
var data = MyListOfModels[];
var result = api.APIController.MyMethod(data);

//API Code
[Route("API/APIController/MyMethod")]
public bool MyMethod(Model[] modelList)
{
    return service.DoSomethingWithModels(ModelList);
}

I'm expecting to be able to send an array to the method which can do something with that array of data.

The connections between the web API and Xamarin are built using Swagger.

Brett Rigby
  • 6,101
  • 10
  • 46
  • 76
Ben Price
  • 61
  • 1
  • 9
  • Hello, and welcome to StackOverflow. Your question as it stands does not contain sufficient information. For example, what technology stack are you using? It looks like C# / WebAPI but this is not clear. Also, you have tagged your question with [swagger] but this appears to have nothing to do with your quesion. – tom redfern Feb 07 '19 at 14:33
  • Possible duplicate of [Posting array of objects with MVC Web API](https://stackoverflow.com/questions/16042853/posting-array-of-objects-with-mvc-web-api) – Andrei Dragotoniu Feb 07 '19 at 15:41
  • Not a duplicate, I am not sending JSON models, they are being sent as C# models but converted into JSON using Swagger. – Ben Price Feb 08 '19 at 16:15

0 Answers0