Q:

Azure C# Cosmos DB: Required property 'id' missing when inserting data

I am creating a program that writes data into a Cosmos DB (OneAuthZDeltaRoleDatabase), however, when I write data, I receive the following error:
"The input content is invalid because the required properties - 'id; ' - are missing"

Below is my code where I programmatically create the Cosmos DB (OneAuthZDeltaRoleDatabase) and its container (OneAuthZDeltaRoleContainer), and attempt to insert the data into the Cosmos DB (the database and the container are successfully created, but inserting data is unsuccessful):
    // Creates the Cosmos DB database where we store the last delta API call for each app
    private static async Task CreateDeltaAPICallDatabaseAsync()
    {
        // Create a new database
        lastAPICallDatabase = await cosmosClient.CreateDatabaseIfNotExistsAsync(lastDeltaDatabaseId);
    }

    // Creates the Cosmos DB container where we store the last delta API for each app
    private static async Task CreateDeltaAPICallContainerAsync()
    {
        // Create a new container
        lastAPICallContainer = await lastAPICallDatabase.CreateContainerIfNotExistsAsync(lastDeltaContainerId, "/AppId");
    }

    /* Timer function that reads the role assignments table (OneAuthZRoleAssignments) on a configurable schedule
     * and computes + displays a mapping of users to their corresponding role assignments (e.x. every 2 mins) */
    [FunctionName("InitiateChangeMonitoring")]
    public static async Task InitiateChangeMonitoring([TimerTrigger("%TimerTriggerPeriod%")] TimerInfo myTimer, ILogger log)
    {
        // Create the necessary Cosmos DB infastructure
        await CreateDeltaAPICallDatabaseAsync();
        await CreateDeltaAPICallContainerAsync();

            foreach (string appId in oneAuthZAppIds)
            {
                // Initialize the base delta API call timestamp for that app id (if it does not exist)
                await lastAPICallContainer.CreateItemAsync(new DeltaAPIMapping(appId, baselineSnapshotTime), new PartitionKey(appId));
            }
     }

This is the code for the DeltaAPIMapping class (the class I am adding to the Cosmos DB).
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;

namespace AccessChangeMonitoring
{
    class DeltaAPIMapping
    {
        [JsonProperty(PropertyName = "AppId")]
        public string id { get; set; }

        public DeltaAPIMapping(string appId, DateTime callTimestamp)
        {
            this.id = Guid.NewGuid().ToString();
            this.appId = appId;
            this.callTimestamp = callTimestamp;
        }

        public string appId { get; set; }
        public DateTime callTimestamp { get; set; }
    }
}

A:

You need the JsonProperty name to be "id", not "AppId". If AppId is what your app needs, then try flipping these and trying again.

