怎么设置HTTP请求方式为MOVE?

ymjavasoft 2012-11-08 10:18:15
public String move(String folderid,String destinationFolderid,String urls) throws IOException{
URL url = new URL(urls);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setRequestMethod("MOVE");
connection.setUseCaches(false);
connection.setInstanceFollowRedirects(true);
connection.setRequestProperty("Content-Type","application/json");
connection.connect();
//MOVE请求
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
JSONObject obj = new JSONObject();
obj.element("destination", destinationFolderid);
out.writeBytes(obj.toString());
out.flush();
out.close();
}
-------------------------------------
报错了
java.net.ProtocolException: Invalid HTTP method: MOVE
at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:333)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:354)
at com.aomei.httprequest.HttpHelper.move(HttpHelper.java:75)
...全文
532 5 打赏 收藏 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
ymjavasoft 2012-11-08
  • 打赏
  • 举报
回复
MOVE https://apis.live.net/v5.0/file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!126 微软API上面写的 To move an audio, make a MOVE request to /AUDIO_IF or /FOLDER_ID, and specify the ID of the destination folder in the request body, as shown here. http://blog.csdn.net/anbo724/article/details/6008640 这个文章里也写了啊,但是不知道怎么用
faping_cao 2012-11-08
  • 打赏
  • 举报
回复

public void setRequestMethod(String method) throws ProtocolException {
	for (int i = 0; i < methods.length; i++) {
	    if (methods[i].equals(method)) {
		this.method = method;
		return;
	    }
	}
	throw new ProtocolException("Invalid HTTP method: " + method);
    }


 /* valid HTTP methods */
    private static final String[] methods = {
	"GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"
    };
不支持
ymjavasoft 2012-11-08
  • 打赏
  • 举报
回复
MOVE https://apis.live.net/v5.0/file.a6b2a7e8f2515e5e.A6B2A7E8F2515E5E!126 微软API上面写的 To move an audio, make a MOVE request to /AUDIO_IF or /FOLDER_ID, and specify the ID of the destination folder in the request body, as shown here. http://blog.csdn.net/anbo724/article/details/6008640 这个文章里也写了啊,但是不知道怎么用
brightyq 2012-11-08
  • 打赏
  • 举报
回复
post
brightyq 2012-11-08
  • 打赏
  • 举报
回复
什么叫http请求是move方式 有 get,poset,put,delete,还没见过move方式的.

62,620

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧