I am trying to send a JSON object to a webapi using aspnetcore. This seems a straightforward task. But, the fieldname of the JSON data includes a dash(-) e.g { Mj-TemplateID : 1}
. Since Newtonsoft.Json is not available for .netcore, so I am not able to use JsonProperty
to change the json fieldname like below.
public class SendData {
[JsonProperty("Mj-TemplateID")]
public string TemplateId { get; set; }
}
How can I specify a different name to be used while sending json data?
I have to send something like this
curl -s \
-X POST \
--user "$MJ_APIKEY_PUBLIC:$MJ_APIKEY_PRIVATE" \
https://api.mailjet.com/v3/send \
-H 'Content-Type: application/json' \
-d '{
"FromEmail":"pilot@mailjet.com",
"FromName":"Mailjet Pilot",
"Subject":"Your email flight plan!",
"MJ-TemplateID":"1",
"MJ-TemplateLanguage":true,
"Recipients":[
{
"Email": "passenger@mailjet.com"
}
]
}'