I am calling Sharepoint 2010 oData with Java, which results in a 400 error. I can connect to the Sharepoint 2010 list in XML format using the same code (using NTLM).
I see a related HttpClient post using both SSL encryption and NTLM authentication , which talks about the same service (listdata.svc) and error 400.
Does anyone know which exact setting was used to fix the error in the above record? Does anyone know if they refer to .NET authorization rules in IIS?
We are using IIS 7.5.
My code is as follows:
String responseText = getAuthenticatedResponse(Url, domain, userName, password);
System.out.println("response: " + responseText);
This method uses Java 1.6 HTTPURLConnection:
private static String getAuthenticatedResponse(
final String urlStr, final String domain,
final String userName, final String password) throws IOException {
StringBuilder response = new StringBuilder();
Authenticator.setDefault(new Authenticator() {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
domain + "\\" + userName, password.toCharArray());
}
});
URL urlRequest = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) urlRequest.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
conn.setRequestMethod("GET");
InputStream stream = conn.getInputStream();
BufferedReader in = new BufferedReader(new InputStreamReader(stream));
String str = "";
while ((str = in.readLine()) != null) {
response.append(str);
}
in.close();
return response.toString();
}
The error I am getting is:
Response Excerpt:
HTTP/1.1 400 Bad Request..Content-Type: application/xml
<message xml:lang="en-US">Media type requires a '/' character. </message>
Microsoft. - , ?
!