New
Updated
No results found
enterReturn key to
select
Arrow keys to navigate
escEscape key to
close
How to Update a DataReplication Resource if the Schema Has Changed
Who is this article for?Ideagen Smartforms users configuring the system.
Understanding of code is required.
If the datasource schema has changed, the Data Replication resource will need to be re-created by:
- Deleting existing data
- Deleting the existing schema
- Uploading a new schema
- 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");
}
}