I'm developing a Transmission client based on the RPC protocol. I'm using web POST's with JSON data to communicate. However, I keep getting:
{
"arguments": {},
"result": "no method name"
}
I'm confused, since I am sure I'm sending a name/value pair for both the method and the arguments. Here is a code snippet:
Code: Select all
// Setup request using POST
httpclient = new DefaultHttpClient();
if (useAuthentication) {
httpclient.getCredentialsProvider().setCredentials(
new AuthScope(address, port), new UsernamePasswordCredentials(username, password));
}
HttpPost httppost = new HttpPost(HTTP + address + PORT_DELIMITER + port + PATH_TO_RPC);
HttpParams params = new BasicHttpParams();
params.setParameter(RPC_METHOD, method);
params.setParameter(RPC_ARGUMENTS, data.toString());
httppost.setParams(params);
// Execute
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
if (entity != null) {
// Read JSON response
InputStream instream = entity.getContent();
String result = convertStreamToString(instream);
JSONObject json = new JSONObject(result);
instream.close();
return json;
}
ElmoTheElk