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.

3
  • 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. Commented Feb 7, 2019 at 14:33
  • Possible duplicate of Posting array of objects with MVC Web API Commented Feb 7, 2019 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. Commented Feb 8, 2019 at 16:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.