UpdateItems
The UpdateItems API inserts updates multiple records in a specified
IDO collection.
Parameters
Name | In | Required? | Description |
---|---|---|---|
responsetype | Path | Yes | Response request data format: Supply any of these values:
|
ido | Path | Yes | This is the name of the IDO collection. |
Headers
Name | Description |
---|---|
Authorization | If the API is called directly, then a Mongoose security token
is obtained through a call to the GetSecurityToken API. If the API is called through ION API, then a valid OAuth2.0 bearer token is provided by ION API. |
X-Infor-MongooseConfig | This is the name of a configuration that is available on the application server. This is required only when using the Mongoose API through the ION API. |
Request data in XML format
<?xml version="1.0"?> <?xml version="1.0"?> <ArrayOfIDOUpdateItem xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.infor.com"> <IDOUpdateItem> <Action>Update</Action> <ItemId>PBT=[UserNames] UserNames.DT=[2019-07-24 13:42:57.280] UserNames.ID=[4b5b7da7-dd7c-47d7-8746-2ce193bfc43a]</ItemId> <Properties> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>UserDesc</Name> <Value>John Doe Sr.</Value> </UpdateProperty> </Properties> </IDOUpdateItem> <IDOUpdateItem> <Action>Update</Action> <ItemId>PBT=[UserNames] UserNames.DT=[2019-07-24 13:28:51.960] UserNames.ID=[3faaaaab-47ef-4643-8255-756976238911]</ItemId> <Properties> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>UserDesc</Name> <Value>Will Kevin Smith</Value> </UpdateProperty> </Properties> </IDOUpdateItem> </ArrayOfIDOUpdateItem>
Request data in JSON format
[ { "Action": 2, "ItemId": "PBT=[UserNames] UserNames.DT=[2019-07-24 13:42:57.280] UserNames.ID=[4b5b7da7-dd7c-47d7-8746-2ce193bfc43a]", "Properties": [ { "IsNull": false, "Modified": true, "Name": "UserDesc", "Value": "John Doe Sr." } ] }, { "Action": 2, "ItemId": "PBT=[UserNames] UserNames.DT=[2019-07-24 13:28:51.960] UserNames.ID=[3faaaaab-47ef-4643-8255-756976238911]", "Properties": [ { "IsNull": false, "Modified": true, "Name": "UserDesc", "Value": "Will Kevin Smith" } ] } ]
Response data in XML format
<?xml version="1.0"?> <MGRestUpdateResponse xmlns="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Message>Update successful.</Message> <MessageCode>201</MessageCode> </MGRestUpdateResponse>
Response data in JSON format
{ "Message": "Update successful.", "MessageCode": 201 }
Example
This example code updates the description of users jdoe and wsmith.
string xml = string.Empty; using ( HttpClient client = new HttpClient() ) { // optionally, you can use json as the response type string ido = "UserNames"; string requestUrl = $"http://localhost/IDORequestService/MGRESTService.svc/xml/{ido}/updateitems"; // provide token in the Authorization header client.DefaultRequestHeaders.TryAddWithoutValidation( "Authorization", "b/XdI6IQzCviZOGJ0E+002…5vl903teP0jSDwkFs" ); List<IDOUpdateItem> idoItems = new List<IDOUpdateItem>(); UpdateProperty userDesc = new UpdateProperty { Name = "UserDesc", Value = "John Doe Sr.", IsNull = false, Modified = true }; IDOUpdateItem idoItem = new IDOUpdateItem { Action = UpdateAction.Update, Properties = new[] { userDesc }, ItemId = "PBT=[UserNames] UserNames.DT=[2019-07-24 13:42:57.280] UserNames.ID=[4b5b7da7-dd7c-47d7-8746-2ce193bfc43a]" }; idoItems.Add( idoItem ); userDesc = new UpdateProperty { Name = "UserDesc", Value = "Will Kevin Smith", IsNull = false, Modified = true }; idoItem = new IDOUpdateItem { Action = UpdateAction.Update, Properties = new[] { userDesc }, ItemId = "PBT=[UserNames] UserNames.DT=[2019-07-24 13:28:51.960] UserNames.ID=[3faaaaab-47ef-4643-8255-756976238911]" }; idoItems.Add( idoItem ); XDocument xdoc = new XDocument( new XDeclaration( "1.0", "utf-8", "yes" ) ); using ( XmlWriter writer = xdoc.CreateWriter() ) { DataContractSerializer serializer = new DataContractSerializer( idoItems.GetType() ); serializer.WriteObject( writer, idoItems ); } // pass the List<IDOUpdateItem> as the request data and send the update request HttpResponseMessage response = client.PutAsync( requestUrl, new StringContent( xdoc.ToString(), Encoding.UTF8, "application/xml" ) ).Result; using ( HttpContent content = response.Content ) { Task<string> result = content.ReadAsStringAsync(); xml = result.Result; } }
You can use these classes to construct the Request Data as demonstrated in the previous code snippets:
public class IDOUpdateItem { public UpdateAction Action { get; set; } public string ItemId { get; set; } public int ItemNo { get; set; } public UpdateProperty[] Properties { get; set; } public UpdateLocking UpdateLocking { get; set; } } public class UpdateProperty { public string Name { get; set; } public string Value { get; set; } public string OriginalValue { get; set; } public bool Modified { get; set; } public bool IsNull { get; set; } } public enum UpdateAction { Insert = 1, Update = 2, Delete = 4 } public enum UpdateLocking { Row = 0, Property = 1 }