How can I make a JSON POST request with LWP?

后端 未结 4 1794
说谎
说谎 2020-12-12 21:03

If you try to login at https://orbit.theplanet.com/Login.aspx?url=/Default.aspx (use any username/password combination), you can see that the login credentials are sent as a

4条回答
  •  情书的邮戳
    2020-12-12 21:54

    Just create a POST request with that as the body, and give it to LWP.

    my $req = HTTP::Request->new(POST => $url);
    $req->content_type('application/json');
    $req->content($json);
    
    my $ua = LWP::UserAgent->new; # You might want some options here
    my $res = $ua->request($req);
    # $res is an HTTP::Response, see the usual LWP docs.
    

提交回复
热议问题