Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^2: REST::Client + Request Body

by ravigupta1 (Novice)
on Jul 09, 2020 at 06:14 UTC ( #11119069=note: print w/replies, xml ) Need Help??

in reply to Re: REST::Client + Request Body
in thread REST::Client + Request Body

Finally it is working. thanks for all help and pointers shared with me which helped me to learn a lot and make it work. For rest of community users (like me 🙂 ) below are the issues and resolutions.

From the Quest REST API documentation,

  • I didn't find what all supported headers should be there in PERL code to support the REST Call.
  • No where was mentioned that authToken OR user/password need to be supplied as Request Body/Content.
  • May be i missed in those things in documentation or due to as i have limited knowledge with Quest and PERL 🙂
  • Anyway, I tried POSTMAN and downloaded the QUEST collection and started working on it and then came to know about above issues and corrective actions and it worked afterwards. For community users, below is the short code for authentication:

    use REST::Client; use JSON qw(decode_json); use Data::Dumper; my $client = REST::Client->new(host => 'https://<Your Host>:<APIPort>/ +api/v1'); $req = "authToken=<Authentication Token Value>"; $headers = { Accept => '*/*', 'Content-Type' => 'application/x-www-form-urlencoded', }; #Below 2 lines are to bypass the SSL verification which was also causi +ng authentication issues. $client->getUseragent()->ssl_opts(verify_hostname => 0); $client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_verify_NONE); $client->POST('/security/login',$req,$headers); print($client->responseCode()); print($client->responseContent()); exit();

    Replies are listed 'Best First'.
    Re^3: REST::Client + Request Body
    by choroba (Archbishop) on Jul 09, 2020 at 09:10 UTC
      #Below 2 lines are to bypass the SSL verification which was also causi +ng authentication issues. $client->getUseragent()->ssl_opts(verify_hostname => 0); $client->getUseragent()->ssl_opts(SSL_verify_mode => SSL_verify_NONE);

      It's dangerous not to verify the certificates, it makes a man-in-the-middle attack possible. If this is for production code, fix the cause instead of silencing the symptoms.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

    Log In?

    What's my password?
    Create A New User
    Domain Nodelet?
    Node Status?
    node history
    Node Type: note [id://11119069]
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (5)
    As of 2022-09-28 08:50 GMT
    Find Nodes?
      Voting Booth?
      I prefer my indexes to start at:

      Results (124 votes). Check out past polls.