我尝试使用以下代码从客户端共享点服务(2013)获取列表,它是一个 https(无效证书),我在 cacets 中下载了相同的证书和安装。每次我得到以下响应
try{
HttpParams params = new BasicHttpParams();
HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
DefaultHttpClient httpClient = new DefaultHttpClient(params);
httpClient.getAuthSchemes().register("ntlm", new NTLMSchemeFactory());
httpClient.getCredentialsProvider().setCredentials(AuthScope.ANY, new
NTCredentials("username", "passwrd", "host", "domain"));
HttpPut request = new HttpPut("https://domain/_api/get..");
request.setHeader("Content-Type", "application/json;odata=verbose");
request.setHeader("Accept", "application/json;odata=verbose");
System.out.println(httpClient.execute(request));
}catch(Exception e){
throw e;
}
RESPONSE
HTTP/1.1 401 Unauthorized [Server: Microsoft-IIS/8.5,
SPRequestGuid: 6ecb4d9f-9884-c0ba-7e4e-eed562a7e616,
request-id: 6ecb4d9f-9884-c0ba-7e4e-eed562a7e616,
X-FRAME-OPTIONS: SAMEORIGIN,
SPRequestDuration: 4,
SPIisLatency: 0,
WWW-Authenticate: NTLM,
X-Powered-By: ASP.NET,
MicrosoftSharePointTeamServices: 15.0.0.5172,
X-Content-Type-Options: nosniff,
X-MS-InvokeApp: 1;
RequireReadOnly,
Date: Thu,
30 Apr 2020 10:02:57 GMT,
Content-Length: 0] org.apache.http.conn.BasicManagedEntity@679b62af