Advertisement
Guest User

skrypcik

a guest
May 28th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. #!/usr/bin/env perl
  2. use strict;
  3. use warnings;
  4. use MIME::Base64;
  5.  
  6. # http://search.cpan.org/~makamaka/JSON/lib/JSON.pm
  7. # Example install using cpanm:
  8. # sudo cpanm -i JSON
  9. use JSON;
  10.  
  11. # http://search.cpan.org/~mcrawfor/REST-Client/lib/REST/Client.pm
  12. # Example install using cpanm:
  13. # sudo cpanm -i REST::Client
  14. use REST::Client;
  15.  
  16. # Set the request parameters
  17. my $host = 'https://opusflowtest.service-now.com';
  18.  
  19. my $desc = $ARGV[0];
  20.  
  21.  
  22. # Eg. User name="admin", Password="admin" for this code sample.
  23. my $user = 'kwiatjo1';
  24. my $pwd = 'password';
  25. my $request_body ="{\"u_sales_invoices_account\":\"$desc\"}";
  26.  
  27. my $client = REST::Client->new(host => $host);
  28.  
  29. my $encoded_auth = encode_base64("$user:$pwd", '');
  30.  
  31. $client->PATCH("/api/now/table/cmn_department/ff4cb624db48f24004877868bf9619a7",
  32. $request_body,
  33. {'Authorization' => "Basic $encoded_auth",
  34. 'Content-Type' => 'application/json',
  35. 'Accept' => 'application/json'});
  36.  
  37. print 'Response: ' . $client->responseContent() . "\n";
  38. print 'Response status: ' . $client->responseCode() . "\n";
  39. foreach ( $client->responseHeaders() ) {
  40. print 'Header: ' . $_ . '=' . $client->responseHeader($_) . "\n";
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement