Question

I get an error every time when the request is called. When I comment the line with request.setPost(false), I get some response from the server. Please explain why this error is appearing.

Exception in thread "Thread-6" java.lang.IllegalStateException: Request method (post/get) can't be modified one arguments

<pre>
<code>
public static void MyVimeo(final String file) {
new Thread(new Runnable() {
public void run() {
Log.p("File Name : " + file);
String consumer_key = "";
String consumer_secret = "";
String vimeoAPIURL = "http://vimeo.com/api/rest/v2";
String reqTokenEP = "http://vimeo.com/oauth/request_token";
String AUTHORIZATION_URL = "http://vimeo.com/oauth/authorize?oauth_token=";
String accTokenEP = "http://vimeo.com/oauth/access_token";
String accToken = "";
String accTokenPass = "";

NetworkManager networkManager = NetworkManager.getInstance();
networkManager.start();
networkManager.addErrorListener(new ActionListener() {

public void actionPerformed(ActionEvent evt) {
NetworkEvent n = (NetworkEvent) evt;
n.getError().printStackTrace();
}
});

ConnectionRequest request = new ConnectionRequest() {
int chr;
StringBuffer sb = new StringBuffer();
String response = "";

protected void readResponse(InputStream input) throws IOException {
// do something with input stream
while ((chr = input.read()) != -1) {
sb.append((char) chr);
// System.out.println("reading...");
}
response = sb.toString();
Log.p("Response->" + response);
if (response.equals("OK")) {
Dialog.show("Response", "Authenticated", "Ok", null);
} 
else {
Dialog.show("Response", "Failed", "Ok", null);
}
}

protected void handleException(Exception err) {
// do something with err
Dialog.show("Connection Err!!", "Are you connected to the internet? Check your connection", "Ok", null);
}
};

request.setUrl(vimeoAPIURL);
request.addArgument("format", "xml");
request.addArgument("method", "vimeo.videos.upload.getQuota");
request.addArgument("oauth_consumer_key", consumer_key);
request.addArgument("oauth_version","1.0");
request.addArgument("oauth_signature_method", "HMAC-SHA1");
request.addArgument("oauth_token", accToken);
Log.p("vimeoAPIURL->" + vimeoAPIURL + " called");
request.setPost(false); //error here

networkManager.addToQueue(request);
}
}).start();
}
</code>
</pre>
Was it helpful?

Solution

setPost must be invoked before adding any arguments. Just invoke it before all the addArgument calls. The actual error is:

"Request method (post/get) can't be modified once arguments have been assigned to the request"

In the current version there is a misspelling where it says one instead of once.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top