By jaceks2106


2019-01-11 12:09:20 8 Comments

How to properly send array of custom objects to asp.net web api via Postman? What I have done is:

Custom class:

public class SystemConsumerConfiguration
    {
        public int SystemId { get; }
        public Uri CallbackUrl { get; }

        public SystemConsumerConfiguration()
        {
        }

        public SystemConsumerConfiguration(int systemId, Uri callbackUrl)
        {
            SystemId = systemId;
            CallbackUrl = callbackUrl;
        }
   }

View model in REST API:

public class PostDigitalPostSubscriptionConfiguration
    {
        public IReadOnlyList<SystemConsumerConfiguration> SystemsModel { get; set; }

        public IFormFile Certificate { get; set; }


        public PostDigitalPostSubscriptionConfiguration()
        {
        }
    }

And now, I make a request in Postman

Postman request

The problem is, that model is bound with default values: Result

1 comments

@jaceks2106 2019-01-11 16:43:07

Forgot to have public setters in SystemConsumerConfiguration.

Should be like this:

public class SystemConsumerConfiguration
    {
        public int SystemId { get; set; }
        public Uri CallbackUrl { get; set; }

        public SystemConsumerConfiguration()
        {
        }

        public SystemConsumerConfiguration(int systemId, Uri callbackUrl)
        {
            SystemId = systemId;
            CallbackUrl = callbackUrl;
        }
   }

Answered in: Default value in an asp.net mvc view model

Related Questions

Sponsored Content

1 Answered Questions

How to send json with byte array to web api / postman

15 Answered Questions

[SOLVED] Pass an array of integers to ASP.NET Web API?

3 Answered Questions

[SOLVED] ASP.NET Web API Authorization with Postman

29 Answered Questions

[SOLVED] How do I get ASP.NET Web API to return JSON instead of XML using Chrome?

11 Answered Questions

[SOLVED] WCF vs ASP.NET Web API

1 Answered Questions

Web Api : Sending XML request through POSTMAN always gives null object

1 Answered Questions

[SOLVED] How to send SOAP request via Postman

6 Answered Questions

[SOLVED] How to secure an ASP.NET Web API

2 Answered Questions

[SOLVED] Sending an array of json objects to web api, how to format the url?

1 Answered Questions

[SOLVED] Web API 2 POST request simulation in POSTMAN Rest Client

Sponsored Content