0

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

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.