AddItems with refresh
The AddItems with refresh API inserts multiple records into a
specified IDO and then refreshes the collection.
POST | /{responsetype}/{ido}/additems/adv |
---|---|
http://localhost/IDORequestService/MGRESTService.svc/xml/UserNames/additems/adv?refresh=ALL&props=Username,UserDesc |
Parameters
Name | In | Required? | Description |
---|---|---|---|
responsetype | Path | Yes | Response request data format Specify any of these values:
|
ido | Path | Yes | The name of the IDO collection |
refresh | Query | No | Provides the instruction to refresh the collection Specify any of these values:
|
props | Query | No | A comma-delimited list of the properties to refresh |
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 | The name of a configuration that is available on the
application server This header is required only when using the Mongoose API through the ION API. |
Request data in XML format
<?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>Insert</Action> <ItemId>PBT=[Usernames]</ItemId> <Properties> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>Username</Name> <Value>jdoe</Value> </UpdateProperty> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>UserDesc</Name> <Value>John Doe </Value> </UpdateProperty> </Properties> </IDOUpdateItem> <IDOUpdateItem> <Action>Insert</Action> <ItemId>PBT=[Usernames]</ItemId> <Properties> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>Username</Name> <Value>wsmith</Value> </UpdateProperty> <UpdateProperty> <IsNull>false</IsNull> <Modified>true</Modified> <Name>UserDesc</Name> <Value>Will Smith</Value> </UpdateProperty> </Properties> </IDOUpdateItem> </ArrayOfIDOUpdateItem>
Request data in JSON format
[ { "Action": 1, "ItemId": "PBT=[Usernames]", "Properties": [ { "IsNull": false, "Modified": true, "Name": "Username", "Value": "jdoe" }, { "IsNull": false, "Modified": true, "Name": "UserDesc", "Value": "John Doe" } ] }, { "Action": 1, "ItemId": "PBT=[Usernames]", "Properties": [ { "IsNull": false, "Modified": true, "Name": "Username", "Value": "wsmith" }, { "IsNull": false, "Modified": true, "Name": "UserDesc", "Value": "Will Smith " } ] } ]
Response data in XML format
<MGRestUpdateResponse xmlns="http://schemas.datacontract.org/2004/07/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Message>Insert successful.</Message> <MessageCode>200</MessageCode> </MGRestUpdateResponse>
Response data in JSON format
{ "Message": "Insert successful.", "MessageCode": 200 }
Example
This example code inserts users jdoe and wsmith as new users and returns the updated property values.
string xml = string.Empty; using ( HttpClient client = new HttpClient() ) { // optionally, you can use json as the response type string ido = "UserNames"; string refresh = "ALL"; string props = "Username,UserDesc"; string requestUrl = $"http://localhost/IDORequestService/MGRESTService.svc/xml/{ido}/additems/adv?refresh={refresh}&props={props}"; // provide token in the Authorization header client.DefaultRequestHeaders.TryAddWithoutValidation( "Authorization", "b/XdI6IQzCviZOGJ0E+002…5vl903teP0jSDwkFs" ); List<IDOUpdateItem> idoItems = new List<IDOUpdateItem>(); UpdateProperty username = new UpdateProperty { Name = "Username", Value = "jdoe", IsNull = false, Modified = true }; UpdateProperty userDesc = new UpdateProperty { Name = "UserDesc", Value = "John Doe", IsNull = false, Modified = true }; IDOUpdateItem idoItem = new IDOUpdateItem { Action = UpdateAction.Insert, Properties = new[] { username, userDesc }, ItemId = "PBT=[UserNames]" }; idoItems.Add( idoItem ); username = new UpdateProperty { Name = "Username", Value = "wsmith", IsNull = false, Modified = true }; userDesc = new UpdateProperty { Name = "UserDesc", Value = "Will Smith", IsNull = false, Modified = true }; idoItem = new IDOUpdateItem { Action = UpdateAction.Insert, Properties = new[] { username, userDesc }, ItemId = "PBT=[UserNames]" }; 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 insert request HttpResponseMessage response = client.PostAsync( 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 }