If the datasource schema has changed, the Data Replication resource will need to be re-created by:

  1. Deleting existing data
  2. Deleting the existing schema
  3. Uploading a new schema
  4. Uploading the new data

Attempting to upload new data (based on the updated schema) to a resource that is defined by the previous schema will fail. 

The SampleDataAdaptor project contains methods to support the last two items ("PUT_SCHEMA" and "PUT_DATA"), however it does not currently contain methods for removing data and removing schema. Here are the methods that may be used to perform these actions:

"DELETE_DATA":
               private static async Task DeleteResourceData(string customerName, string resource, Uri serverUrl)
        {
            // set Timeout to 30 minutes for debugging purposes
            using (var client = new HttpClient() { Timeout = new TimeSpan(0, 30, 0) })
            {
                client.BaseAddress = serverUrl;
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                authManager.credService.AddEncryptedCredentialsToClient(client, authManager.UserName, authManager.EncryptedPassword, authManager.ClientKey);
               
                HttpResponseMessage response = await client.DeleteAsync("" + customerName + "/" + resource);
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Data delete successful");
                }
                else
                    Console.WriteLine("Data delete failed");
            }
        }


"DELETE_SCHEMA":

        private static async Task DeleteResourceSchema(string customerName, string resource, Uri serverUrl)
        {
            // set Timeout to 30 minutes for debugging purposes
            using (var client = new HttpClient() { Timeout = new TimeSpan(0, 30, 0) })
            {
                client.BaseAddress = serverUrl;
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                authManager.credService.AddEncryptedCredentialsToClient(client, authManager.UserName, authManager.EncryptedPassword, authManager.ClientKey);
                // HttpResponseMessage response = await client.PutAsJsonAsync("" + customerName + "/" + resource, "");
                HttpResponseMessage response = await client.DeleteAsync("_/" + customerName + "/" + resource);
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Schema delete successful");
                }
                else
                    Console.WriteLine("Schema delete failed");
            }
        }