1

I am Using apache Http Client for connecting sharepoint using rest api.

code snippet is as below:

HttpClient client = HttpClientBuilder.create().build();
String baseurl = messages.getString("baseurl");
HttpPost post = new HttpPost(baseurl + "_api/contextinfo");
post.setHeader("Accept", "application/json; odata=verbose");
post.setHeader("content-type", "application/json; odata=verbose");
//post.setHeader("DataServiceVersion", "3.0");  
//post.setHeader("Content-Length", "2");

post.addHeader("Cookie", cookie);
System.out.println("post===>"+cookie);
System.out.println("post===>"+post);

HttpResponse response = client.execute(post);
System.out.println("response===>"+response.toString());
int httpStatus = 0;
if (null != response && null != response.getStatusLine()) {
     httpStatus = response.getStatusLine().getStatusCode();
}

I am getting an error. Please help me.

1
  • check if the variable baseurl contains a "/" in the end or not? I guess you are forgetting to put a forward slash in the beginning of /_api/contextinfo Commented Feb 6, 2019 at 8:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.