A week ago I started a new project with my Arduino MEGA 2560 with Ethernet Shield. I'm able to send a WOL to my server but now I want to PING my XBMC server with the JSON-RPC command. With my Chrome browser I'm able to check the server with follwoing HTTP GET request:
http://192.168.5.34/jsonrpc?request={"jsonrpc": "2.0", "id": 1, "method": "JSONRPC.Ping"}
And as a result I get a clean PONG back from the XBMC server:
{"id":1,"jsonrpc":"2.0","result":"pong"}
Now I tried to do this with my Arduino with the following code that is embedded in a function:
EthernetClient client;
IPAddress server(192,168,5,34);
if (client.connect(server, 80))
{
Serial.println("Connecting to Client...");
client.print("GET /jsonrpc?request={%22jsonrpc%22:%20%222.0%22,%20%22id%22:%201,%20%22method%22:%20%22JSONRPC.Ping%22} HTTP/1.1\r\n");
client.print("Host: 192.168.5.34\r\n");
client.print("User-Agent: Mozilla/5.0\r\n");
client.print("Connection: close\r\n\r\n");
}
else
Serial.println("Client Connection Failed!");
With my Arduino a got following return:
HTTP/1.1 401 Unauthorized
Content-Length: 0
Connection: close
WWW-Authenticate: Basic realm=XBMC
Date: Fri, 06 Jun 2014 21:33:24 GMT
I can make a GET request to Google with my Arduino so it's really XBMC that for some reason does not accept my GET request. Anyone got an idea why? I used Wireshark to sniff the network data on the server and the request and return are present in Wireshark.
Is there maybe a way to login on the XBMC server by GET or POST?
Thanks for the help guys! :)