问题描述
- java 调用 rest 接口 怎么写请求行的信息?
-
Rest接口格式:每一个请求通常由三部分组成:请求行、请求报头、请求正文(可选)。请求样例:
Post /services/ita/login HTTP/1.1
Host: https://:
Accept:application/json;charset=UTF-8;Content-Type:application/json; charset=UTF-8
Accept-Language:zh_CN
X-Auth-User:user
X-Auth-Key:password通过下面的代码,我可以设置请求属性。 URL httpurl = new URL(url); HttpURLConnection conn = (HttpURLConnection) httpurl.openConnection(); conn.setDoInput(true); conn.setDoOutput(true); conn.setUseCaches(false); conn.setDefaultUseCaches(false); conn.setRequestProperty("Content-Type", "text/xml; charset=utf-8"); conn.setRequestProperty("Content-Length", String.valueOf(xml.length())); conn.setRequestProperty("SOAPAction", ""); conn.setConnectTimeout(60*1000); conn.setReadTimeout(60*1000); conn.setRequestMethod("POST"); 但是怎么在java代码里写请求行:Post <basic_uri>/services/ita/login HTTP/1.1的信息呢?
解决方案
[[http://docs.neo4j.org.cn/server-java-rest-client-example.html]
时间: 2024-11-01 13:11:26