I am trying to decode the input parameter which is URL encoded.
The input parameter looks like this
json=%7B%0A%22MouseSampleBarcode%22%20%3A%20%22MOS81%22%0A%7D%0A
I have this model class:
public class CoreBarCodeDTO
{
private string _json;
public string json
{
get { return _json; }
set
{
string decoded = HttpUtility.UrlDecode(value);
_json = decoded;
}
}
}
In my controller I am trying to parse this and trying to retrieve the MouseSampleBarCode
:
[HttpPost]
public async Task<IHttpActionResult> Post([FromBody] CoreBarCodeDTO coreBarCode)
{
string inputJson = coreBarCode.json;
dynamic results = JsonConvert.DeserializeObject<dynamic>(inputJson);
string Bar_Code = results.MouseSampleBarcode;
When I try to debug this using fiddler
I am getting this error
System.NullReferenceException: An error has occurred
Object reference not set to an instance of an object.