Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

Get parameter like object, ASP.NET Core

$
0
0

I have a controller like this :

[HttpPatch("{documentId}")]
public IActionResult UpdateDocument(Guid departmentId, Guid documentId, DocumentForUpdateDto docFromRequest) { // Do somethings .... }

This is the DocumentForUpdateDto class :

public class DocumentForUpdateDto
{
    public string UpdatedBy { get; set; }
    public DateTime UpdatedDate { get; set; }
    public string Comment { get; set; }
    public IFormFile File { get; set; }
    public IEnumerable<TagKeyValue> RawsTags { get; set; }
}

This is the TagKeyValue class : 

public class TagKeyValue
{
    public string Key { get; set; }
    public object Value { get; set; }
}

This is the POST request POSTMAN in form-data Body, I tried to put something similar because I can't put images here:

....
RawsTags[0][Key]   (Text) : PolicyNum
RawsTags[0][Value] (Text) : 789
RawsTags[1][Key]   (Text) : OwnerName
RawsTags[1][Value] (Text) : Lolo
....

When I run the application and I send the above postman request I got a null value in the parameter Value of TagKeyValue class.

I am doing the thing have an object parameter because I don't know what the client send me, he can send me an integer, string, DateTime or Bool, so that I need an object parameter in TagKeyValue, I thing so.

What am I doing wrong ??? Thanks !!


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>