I am building an API base on an Adyen Webhook and it seems like the JsonProperty is not being 'read'.
So I built a proof of concept by creating a model NotifyRequest.cs. For one of the properties I have defined [JsonProperty("NotificationItems")] but when posting JSON via Postman, the property is NULL. The "Live" property is being fed through.
NotifyRequest.cs:
using Newtonsoft.Json;
using System.Collections.Generic;
using web_external_payments.Models;
namespace web_external_payments.Models
{
public class NotifyRequest
{
// public NotifyRequest();
public string Live { get; set; }
[JsonProperty("NotificationItems")]
public List<NotifyRequestItemContainer> NotifyItemContainers { get; set; }
//public string ToJson();
//public override string ToString();
}
}
Controller:
[HttpPost]
public ActionResult Webhook(NotifyRequest notificationRequest)
{
return View("Error");
}
JSON payload:
{
"Live":"false",
"NotificationItems":[
{
"NotificationItem":{
"eventCode":"AUTHORISATION",
"success":"true",
"eventDate":"2019-06-28T18:03:50+01:00",
"merchantAccountCode":"YOUR_MERCHANT_ACCOUNT",
"pspReference": "7914073381342284",
"merchantReference": "YOUR_REFERENCE"
}
}
]
}
However, if I instead post the JSON but use the name of the property instead (NotifyItemContainer), it does pick up the values in that JSON and is no longer NULL.
I am on .NET 4.7.2. Is there something with this particular .NET version where it's not using the JsonProperty or have I missed something completely?