in reply to How to Post a HTTP Request for a JSON web page?

Try  use Data::Dump qw/ dd /; dd( $res->as_string );

Replies are listed 'Best First'.
Re^2: How to Post a HTTP Request for a JSON web page?
by vchinnat (Initiate) on Mar 26, 2014 at 09:08 UTC

    I'm not sure on the content ($json) variable I passed in the script. I assumed the below code works.

    my $json = '[{"action":"http:/cisco.com/jnap/wirelessap/SetRadioSe +ttings","request":{"radios":[{"radioID":"RADIO_2.4GHz","settings":{"i +sEnabled":true,"mode":"802.11bgn","ssid":"vinoth","broadcastSSID":tru +e,"channelWidth":"Auto","channel":1,"security":"None"}}]}},{"action": +"http://cisco.com/jnap/guestnetwork/SetGuestNetworkSettings","request +":{"isGuestNetworkEnabled":false,"guestSSID":"vinoth-guest","guestPas +sword":"BeMyGuest","maxSimultaneousGuests":5,"broadcastGuestSSID":fal +se}}] '; my $req = HTTP::Request->new(POST=>$url); $req->header('content-type' => 'application/json'); $req->authorization_basic("admin", "admin"); $req->content($json);

      I'm not sure on the content ($json) variable I passed in the script. I assumed the below code works.

      I didn't ask about the content of the request, I asked about the content of the response

      Either one of two things is going on, you're running this as CGI and its failing because its not a CGI (no headers like FAQ says)

      Or the response is 500 for some reason ...

      So fix the cgi headers if that is the issue

      Of examine (or show) the response to see if it says something more , to make sure it is a server response and not internal lwp response

        Below are the response received.

        "HTTP/1.1 500 Internal Server Error\nConnection: close\nDate: Tue, 14 Aug 2012 05:40:24 GMT\nServer: lighttpd/1.4.28\nContent-Length: 385\nClient-Date: Wed, 26 Mar 2014 10:39:42 GMT\nClient-Peer: 192.168.1.1:80\nClient-Response-Num: 1\nStatus: 500 Internal Server Error\n\n<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"\n \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n <head>\n <title>500 - Internal Server Error</title>\n </head>\n <body>\n

        500 - Internal Server Error

        \n

        closed

        \n </body>\n</html>\n"