user44036 user44036 - 3 months ago 16
C# Question

Posting a List of GUIDs to a MVC 5 Controller with Postman

I'm attempting to make a controller method:

public String CreateGasolineBlend(List<Guid> enumerableTransferIDs)

Accept a list of GUIDs. However, the list is always null when I'm using postman.

I tried using this article to find out how to format the request:

Is it possible to send an array with the Postman Chrome extension?

But I'm unsure if MVC even is capable of accepting a List of objects using a Post Method, or if perhaps I am incorrectly formatting the POST request in Postman.

(I am using what the previous stack overflow question states, arr[0], arr[1] or arr[], arr[] with Guids as values.)

Is my problem with the way I'm receiving the values in the controller, or is it a problem with how I'm using Postman?


MVC is capable of accepting a list objects and map it to the action method parameter.

You need to make sure you are using the correct Content-Type header value when send the data. "application/json" should work.

I just updated your action method to return the posted data along with the item count in a json structure to verify this.

public ActionResult CreateGasolineBlend(List<Guid> enumerableTransferIDs)
    return Json(new { ItemCount= enumerableTransferIDs.Count(),
                      Items= enumerableTransferIDs});

You can see the response came back with the data we posted.

enter image description here