The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

ServiceNow::JSON - Absraction Library for ServiceNow JSON WebServices

DESCRIPTION

Allows for easy use of the ServiceNow JSON REST api from perl. Supports both ServiceNow JSON and ServiceNow JSONv2 implementations.

SYNOPSIS

use ServiceNow::JSON;

my $sn = new ServiceNow::JSON( instance => "my_sn_instance", user => "foo", password => "bar" );

my $record = $sn->get( "cmdb_ci_computer", "72542ce36f015500e5f95afc5d3ee423" );

my $records = $sn->getRecords( "cmdb_ci_computer", { serial_number => '1234567' } );

my $keys = $sn->getKeys( "cmdb_ci_computer", { active => "true" } );

my $update = $sn->update( "cmdb_ci_computer", { sys_id => '0014eca36f015500e5f95afc5d3ee4af' }, { cpu_name => "kevin_test_another" } );

my $insert = $sn->insert( "cmdb_ci_computer", { serial_number => "1234567" } );

my $multi_insert = $sn->insert( "cmdb_ci_computer", [ { serial_number => "222222" }, { serial_number => "111111" } ] );

my $delete = $sn->delete( "cmdb_ci_computer", '0014eca36f015500e5f95afc5d3ee4af' );

my $delete_multi = $sn->deleteMultiple( "cmdb_ci_computer", { serial_number => "111111" } );

DESCRIPTION

If you need to use version 1 of the ServiceNow JSON API, pass legacy => 1 to the contructor. "Instance" in the contructor represents the part of the service now url that is before service-now.com. So instance.service-now.com.

METHODS

get

Accepts a table/record name and a sys_id for that record, returns an arrayref with either 0 or 1 elements. The elements will be a hashref of the ServiceNow object.

getRecords

Accepts a table/record name and a hashref of query terms, multiple terms are ANDed together, API does not support OR type clauses. Returns all objects in an arrayref that match that query.

getKeys

Accepts a table/record name and a hashref of query terms. Returns an arrayref of sys_ids for all objects that match the query criteria.

update

Accepts a table/record name, a hashref of query parameters and a hashref of the changes you wish to make. Multiple query parameters are ANDed together, works the same as getRecords and getKeys. Returns an arrayref of the objects that were updated.

insert

Accepts a table/record name and either an array or hashref of the data you wish to enter. If you pass an arrayref it will detect this and pass the call onto insertMultiple. Returns an arrayref of the records that were just created.

insertMultiple

Accepts a table/record name and an arrayref of the records you want to insert. Returns an arrayref of the records that were just created.

delete

Accepts a table/record name and a sys_id of the record you wish to delete. Will only ever delete a single record. Returns the record that you just deleted in an arrayref.

deleteMultiple

Accepts a table/record name and a hashref of query terms. Will delete ALL records that match those query terms. Returns arrayref of the objects that were deleted.

SEE ALSO

Moose

REST::Client

MIME::Base64

JSON

https://wiki.servicenow.com/index.php?title=JSON_Web_Service

https://github.com/klkane/servicenow-json

AUTHOR

Kevin L. Kane, <kkane@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Kevin L. Kane

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2 POD Errors

The following errors were encountered while parsing the POD:

Around line 263:

alternative text 'https://wiki.servicenow.com/index.php?title=JSON_Web_Service' contains non-escaped | or /

Around line 265:

alternative text 'https://github.com/klkane/servicenow-json' contains non-escaped | or /