Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ServiceNow 2

Status
Not open for further replies.

ljsmith91

Programmer
May 28, 2003
305
0
0
US
I am trying to use PERL to access Service Now database using the ServiceNow API provided. I could not find any threads pertaining to this. I hope someone might be able to give me some direction.

All necessary Modules are installed. I pulled the code attempted from sample code from on how to query ServiceNow records. Code is almost exactly as appears in example on this site. Problem is, when I execute, it fails with:

Can't call method "getUserName" on an undefined value at C:/Perl64/site/lib/ServiceNow/Connection.pm line 39.

The Connection.pm at line 39 has this:

# implement SOAP::Lite's basic auth strategy
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
return $CONFIG->getUserName() => $CONFIG->getUserPassword();
}

Any idea what this error is telling me or how I can correct this? I really need any help or direction you could offer. Thanks.

Below is the code I am using which is exactly as suggested except where specific to my site.

use ServiceNow::SOAP;
my $username = "ServiceNow_acct";
my $password = "servicenow_pw";

my $sn = ServiceNow(" $username, $password);
my $table = $sn->table("cmdb_ci_server");
my @serverData = $table->query("operational_status=1")->fetchAll();
foreach my $serverRec (@serverData) {
print $serverRec->{name}, "\n";
}

# end code
 
Where is $CONFIG being set?

What happens if you override the method in your code as shown in solution 1?

Code:
sub SOAP::Transport::HTTP::Client::get_basic_credentials {
    return $username => $password;
}

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music
 
You are probably using both ServiceNow::Configuration and ServiceNow::SOAP. Both of these modules override the function SOAP::Transport::HTTP::Client::get_basic_credentials, however they are not compatible with each other. You need to use one or the other.
 
Thanks gflewis, I was using multiple mods.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top