I'm getting started with CosmosDB now and I'm running into the following error when trying to insert some data in the database:
The input content is invalid because the required properties - 'id; ' - are missing.
I understand that there should be a string field called id in my document, but the error persists even after I add [JsonPropertyName("id")] as an annotation to my object's Id field.
Here's the call to CosmosDB:
var insertionResponse = await container.CreateItemAsync<Article>(
item: article,
partitionKey: new PartitionKey(article.Id.ToString())
);
And here's the Article class:
public partial class Article
{
[JsonPropertyName("id")]
public Guid Id { get; set; }
public Guid CreatedBy { get; set; }
public DateTime CreatedOn { get; set; }
public string Title { get; set; }
public string Body { get; set; }
}
Any ideas why this is happening?