Get a list of incidents

jspatton1971
Kilo Explorer

I'm just getting started with servicenow integrations and c-sharp. I've been working in c-sharp for a while, but don't think i'd call myself an expert. I tend to start small and work up so for my first task, I wanted to create an app that would return a list of active incidents. Early on I was getting access errors but have updated my app.config with the appropriate transport information, I also had to add a maxRecevievedMessageSize as I was getting an error that I was exceeding that.

My code is fairly straightforward and I *think* it should work. Please let me know what I'm doing wrong here? I have one incident that is active in my test instance, and i'm logged in as admin, and that is the user who created and is assigned to the one active incident.

ServiceNOW.ServiceNowSoapClient soapClient = new ServiceNOW.ServiceNowSoapClient();
soapClient.ClientCredentials.UserName.UserName = "blah";
soapClient.ClientCredentials.UserName.Password = "blah";

ServiceNOW.getRecords Records = new ServiceNOW.getRecords();
Records.state = "Active";
ServiceNOW.getRecordsResponseGetRecordsResult[] Results = soapClient.getRecords(Records);
foreach (ServiceNOW.getRecordsResponseGetRecordsResult Result in Results)
{
string consoleReturn = Result.sys_id + " " + Result.opened_by + " " + Result.short_description;
Console.WriteLine(consoleReturn);
}

10 REPLIES 10

Yes, your user needs to have the soap role or be a member of a group with that role. Also the table you are doing things to, your user would need permissions to that too.