Topic by Shai Hangel
Content
Hello,
Is there any example of how to use API in C#, for INSERT new record in “Account” ?
(not by creating xml data. I mean by objects)
Is RN need to set special permission to my environment for using this option?
Maybe some kind of “write permission”, as same as the “II_CONNECT_ENABLED” configuration?
I found this answer earlier:
http://communities.rightnow.com/posts/dcbed994fd?commentId=28978#28978
“The II_CONNECT_ENABLED configuration has to be set to true. This is a hidden configuration entry, meaning it cannot be enabled by customers, only RN.”
)
I wrote some code like this, and I get “Access denied”:
Is something missing?
where can I get the documentation/samples for API?
RightNowSyncPortClient _client;
_client = new RightNowSyncPortClient();
_client.ClientCredentials.UserName.UserName = "[my user]";
_client.ClientCredentials.UserName.Password = "[my password]";
Account acc = new Account();
acc.ID = new ID();
PersonFullName pfn = new PersonFullName();
pfn.First = "MyFirstName";
pfn.Last = "MyLastName";
acc.Name = pfn;
acc.DisplayName = "FirstLast";
//Build an Email object
Email email = new Email();
email.action = ActionEnum.add;
email.actionSpecified = true;
email.Address = "shai.hangel@pdgm.com";
NamedID emailType = new NamedID();
emailType.ID = new ID();
emailType.ID.id = 0;
emailType.ID.idSpecified = true;
email.AddressType = emailType;
acc.Emails = new Email[] { email };
//…….
//…….
//…….
//…….
//Build the RNObject[]
RNObject[] newObjects = new RNObject[] { acc };
//Set the processing options
CreateProcessingOptions options = new CreateProcessingOptions();
options.SuppressExternalEvents = false;
options.SuppressRules = false;
//Invoke the Create Operation
try
{
ClientInfoHeader clientInfoHeader = new ClientInfoHeader();
clientInfoHeader.AppID = "Basic Create";
RNObject[] results = _client.Create(clientInfoHeader, newObjects, options);
System.Console.WriteLine("\nNew account with ID: " + results[0].ID.id + " created.");
System.Console.WriteLine("New account with ID: " + results[0].ID.id + " created.");
System.Console.ReadLine();
}
catch (Exception ex)
{
//Console.WriteLine(ex.Code);
Console.WriteLine(ex.Message);
}
//…
Thanks,
Shai.