0

If I pass single object like below, My controller is showing the data.

My C# library project.

var client = new HttpClient();
var response = await client.PostAsync(uri, myRequestObject, new JsonMediaTypeFormatter());

My Controller looks like this.

public async Task<Response> Execute(Request request)
    {
        this.Logger.Debug("Initializing Controller");

        return await Task.Run(() => ExecuteRequest());
    }

The above code is working and I am receiving the data from C# library.

I want to pass list of objects like this

var objectList = new List<RequestObject> { myRequestObject}
var client = new HttpClient();
var response = await client.PostAsync(uri, objectList , new JsonMediaTypeFormatter());

And I want my controller like this.

public async Task<Response> Execute(List<Request> request)
    {
        this.Logger.Debug("Initializing Controller");

        return await Task.Run(() => ExecuteRequest());
    }

Passing list is not working.

1 Answer 1

3

Try adding [FromBody] to your argument

public async Task<Response> Execute([FromBody] List<Request> request)
Sign up to request clarification or add additional context in comments.

1 Comment

If this answer helped you, consider ticking it as right.

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.