A Microsoft framework for building cross-platform mobile apps using .NET and C# with native performance and user interfaces.
Try something like this:
var data = new
{
app_id = SecureStorage.GetAsync("AppID").Result,
headings = string.IsNullOrWhiteSpace(TextBoxNewMessageTitle.Text) ? null : new
{
en = TextBoxNewMessageTitle.Text.Trim()
},
subtitle = string.IsNullOrWhiteSpace(TextBoxNewMessageSubtitle.Text) ? null : new
{
en = TextBoxNewMessageSubtitle.Text.Trim()
},
contents = string.IsNullOrWhiteSpace(EditorMessage.Text) ? null : new
{
en = EditorMessage.Text.Trim()
},
url = "https://www.cnn.com",
included_segments = "All",
};
var o = new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
string json = JsonSerializer.Serialize( data, o);
var content = new StringContent( json, Encoding.UTF8, "application/json");