vchinnat has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to configure the wireless settings (like setting ssid as "vinoth" channel as "1") in Linksys EA4500 AP. I could see the below POST message using wireshark.
3E@@!dPzY+2K SPOST /JNAP/ HTTP/1.1 Host: 192.168.1.1 User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:22.0) Gecko/20100 +101 Firefox/22.0 Accept: */* Accept-Language: en-US,en;q=0.5 Accept-Encoding: gzip, deflate Content-Type: application/json; charset=UTF-8 X-JNAP-Action: http:cisco.com/jnap/core/Transaction X-JNAP-Authorization: Basic YWRtaW46YWRtaW4= X-Requested-With: XMLHttpRequest Referer: http://192.168.1.1/ Content-Length: 474 Cookie: initial-tab=; ui-proxy-path=local; admin-auth=Basic%20YWRtaW46 +YWRtaW4%3D; current-applet=7B1F462B-1A78-4AF6-8FBB-0C221703BEA4 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache [{"action":"http:/cisco.com/jnap/wirelessap/SetRadioSettings","request +":{"radios":[{"radioID":"RADIO_2.4GHz","settings":{"isEnabled":true," +mode":"802.11bgn","ssid":"vinoth","broadcastSSID":true,"channelWidth" +:"Auto","channel":1,"security":"None"}}]}},{"action":"http://cisco.co +m/jnap/guestnetwork/SetGuestNetworkSettings","request":{"isGuestNetwo +rkEnabled":false,"guestSSID":"vinoth-guest","guestPassword":"BeMyGues +t","maxSimultaneousGuests":5,"broadcastGuestSSID":false}}]
I tried automating the above action using Perl but it didn't workout. As I am new to this JSON page I don't know how exactly the POST message to be sent.
Below is the code I tried but got "500 Internal Server Error".
use strict; use warnings; use LWP; my $ua = LWP::UserAgent->new; my $ip = $self->{ip}; my $url = "http://$ip/"; 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); my $res = $ua->request($req); if ($res->is_success) { my $message = $res->decoded_content; print "received the message"; } else { print "HTTP get code: ", $res->code, "\n"; print "HTTP get: msg: ", $res->message, "\n"; }
Please help me in fixing this. Awaiting for your valuable reply.
|
|---|