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

jspatton1971
Kilo Explorer

I'm not really sure what changed, but I right clicked on the service reference for servicenow and did an update service reference, i'm not getting information back.


Did you check the ElementFormDefault setting that I pointed to in my first response? It sure sounds like it could be related to that. You need to set that appropriately in your instance and then reload the WSDL in your C# app...hopefully that gets rid of the null responses.


Yes, that was unchecked.


john_andersen
Tera Guru

yeah, everything is a "string" to the servicenow Web Service API, even the integer based variables. Glad you got it going.


Last question for this, are there special rights/security that needs to be assigned for a regular user (read service account) to be able to use the api? when I run against our test instance as admin (of course) it just works, but when I switch to the production side I get a 401.