SaveJson
The SaveJson method modifies a collection (inserting, updating, or deleting records)
using the UpdateCollection method of an IDO, using JSON.
Syntax
public string SaveJson( string strSessionToken, string updateJsonObject, string strCustomInsert, string strCustomUpdate, string strCustomDelete )
Parameters
Name | Description |
---|---|
strSessionToken | This is the session token obtained through a call to the CreateSessionToken API. |
updateJsonObject | This parameter specifies a JSON object that contains records to be updated. |
strCustomInsert | This parameter is a comma-delimited list of methods and/or instructions which override the default save behavior. |
strCustomUpdate | This parameter is a comma-delimited list of methods and/or instructions which override the default save behavior. |
strCustomDelete | This parameter is a comma-delimited list of methods and/or instructions which override the default save behavior. |
Output
None
Example 1 – Insert action using SaveJson
string sessionToken = "b/XdI6IQzCviZOGJ0E+002…5vl903teP0jSDwkFs"; // property values to insert PropertyStatusPair username = new PropertyStatusPair() { Property = "jdoe1", Updated = true }; PropertyStatusPair userDesc = new PropertyStatusPair() { Property = "John Doe", Updated = true }; // row to insert SimpleIDOItem idoItem = new SimpleIDOItem { EditStatus = SimpleIDOItem.Modified.Inserted, Properties = new List<PropertyStatusPair>() { username, userDesc } }; SimpleIDOItemList insertRequest = new SimpleIDOItemList { IDOName = "UserNames", PropertyList = new[] { "Username", "UserDesc" }, Items = new List<SimpleIDOItem>() }; insertRequest.Items.Add( idoItem ); IDOWebService.DOWebServiceSoapClient soapClient = new IDOWebService.DOWebServiceSoapClient(); // provide the insertRequest as the payload string payload = JsonConvert.SerializeObject( insertRequest ); string result = soapClient.SaveJson( sessionToken, payload, string.Empty, string.Empty, string.Empty );
Example 2 – Update action using SaveJson
string sessionToken = "b/XdI6IQzCviZOGJ0E+002…5vl903teP0jSDwkFs"; // property values to update PropertyStatusPair userDesc = new PropertyStatusPair() { Property = "John Doe Sr.", Updated = true }; // row to update SimpleIDOItem idoItem = new SimpleIDOItem { EditStatus = SimpleIDOItem.Modified.Modified, ID = "PBT=[UserNames] UserNames.DT=[2019-07-29 12:54:00.937] UserNames.ID=[6565e11a-80d8-43de-b91e-951df7867816]", Properties = new List<PropertyStatusPair>() { userDesc } }; SimpleIDOItemList updateRequest = new SimpleIDOItemList { IDOName = "UserNames", PropertyList = new[] { "UserDesc" }, Items = new List<SimpleIDOItem> { idoItem } }; IDOWebService.DOWebServiceSoapClient soapClient = new IDOWebService.DOWebServiceSoapClient(); // provide the updateRequest as the payload string payload = JsonConvert.SerializeObject( updateRequest ); string result = soapClient.SaveJson( sessionToken, payload, string.Empty, string.Empty, string.Empty );
Example 3 – Delete action using SaveJson
string sessionToken = "b/XdI6IQzCviZOGJ0E+002…5vl903teP0jSDwkFs"; PropertyStatusPair userDesc = new PropertyStatusPair() { Property = "John Doe Sr.", Updated = true }; // row to delete SimpleIDOItem idoItem = new SimpleIDOItem { EditStatus = SimpleIDOItem.Modified.Deleted, ID = "PBT=[UserNames] UserNames.DT=[2019-07-29 12:55:22.173] UserNames.ID=[41ef60ef-1ec8-4740-9a52-ea361fbe83de]", Properties = new List<PropertyStatusPair>() }; SimpleIDOItemList deleteRequest = new SimpleIDOItemList { IDOName = "UserNames", PropertyList = new[] { "UserDesc" }, Items = new List<SimpleIDOItem>() }; deleteRequest.Items.Add( idoItem ); IDOWebService.DOWebServiceSoapClient soapClient = new IDOWebService.DOWebServiceSoapClient(); // provide the deleteRequest as the payload string json = JsonConvert.SerializeObject( deleteRequest ); string result = soapClient.SaveJson( sessionToken, json, string.Empty, string.Empty, string.Empty );
Helper classes for the examples
You can use these classes to help construct the request as demonstrated in the code snippets above:
public class SimpleIDOItemList { public string IDOName { get; set; } public string[] PropertyList { get; set; } public List<SimpleIDOItem> Items; } public class SimpleIDOItem { public enum Modified { Unmodified, Modified, Deleted, Inserted } public string ID { get; set; } public List<PropertyStatusPair> Properties; public Modified EditStatus { get; set; } } public struct PropertyStatusPair { public string Property { get; set; } public bool Updated { get; set; } }