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

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);

Replies are listed 'Best First'.
Re^3: How to Post a HTTP Request for a JSON web page?
by Anonymous Monk on Mar 26, 2014 at 10:00 UTC

    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"

        well, that means the webserver (bartender) is sick -- there is nothing you can do about it (problem at their end)

        The problem might be as simple as no proper error checking, so when you send the webserver(bartender) questionable json values, its just explodes into 500 instead of doing what it was supposed to do

        There is just no way of guessing ... other than recording/reproducing verbatim existing browser sessions, in most every conceivable detail ... all those various headers you're not including like X-JNA....

        I have tried given all the options like X-JNAP-Action, X-JNAP-Authorization, Content_type, charset to the headers but still it didn't help. I have no clue to fix this.