Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- use strict;
- use warnings;
- use MIME::Base64;
- # http://search.cpan.org/~makamaka/JSON/lib/JSON.pm
- # Example install using cpanm:
- # sudo cpanm -i JSON
- use JSON;
- # http://search.cpan.org/~mcrawfor/REST-Client/lib/REST/Client.pm
- # Example install using cpanm:
- # sudo cpanm -i REST::Client
- use REST::Client;
- # Set the request parameters
- my $host = 'https://opusflowtest.service-now.com';
- my $desc = $ARGV[0];
- # Eg. User name="admin", Password="admin" for this code sample.
- my $user = 'kwiatjo1';
- my $pwd = 'password';
- my $request_body ="{\"u_sales_invoices_account\":\"$desc\"}";
- my $client = REST::Client->new(host => $host);
- my $encoded_auth = encode_base64("$user:$pwd", '');
- $client->PATCH("/api/now/table/cmn_department/ff4cb624db48f24004877868bf9619a7",
- $request_body,
- {'Authorization' => "Basic $encoded_auth",
- 'Content-Type' => 'application/json',
- 'Accept' => 'application/json'});
- print 'Response: ' . $client->responseContent() . "\n";
- print 'Response status: ' . $client->responseCode() . "\n";
- foreach ( $client->responseHeaders() ) {
- print 'Header: ' . $_ . '=' . $client->responseHeader($_) . "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement