0

This question already has an answer here:

i have trying to create a document libary by using SharePoint rest api but how do i add the body content with the post in Java?

body: { '__metadata': { 'type': 'SP.List' }, 'AllowContentTypes': true, 'BaseTemplate': 101,
 'ContentTypesEnabled': true, 'Description': 'My Documents Library', 'Title': 'Documents' }

marked as duplicate by Waqas Sarwar MVP, Vadim Gremyachev, Eric Alexander Apr 9 '15 at 2:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Please, see my answer in this thread.

As far as I the official documentation of this API, and other samples on the web (like this and this one) understand, the body of the request can be set in this case as a StringEntity instance via the setEntity method of the HttpPost object:

String jsonString = "{ '__metadata': { 'type': 'SP.List' }, 'AllowContentTypes': true, 'BaseTemplate': 101,
 'ContentTypesEnabled': true, 'Description': 'My Documents Library', 'Title': 'Documents' }";
HttpEntity e = new StringEntity(jsonString);
httpPost.setEntity(e);
  • When i execute the method i get a http 500 – user3476614 Apr 8 '15 at 12:39
  • Use Fiddler to see the exact request sent to the server and the response received. See the ULS logs and Windows Event Logs (Application) for the error details of the Internal Server Error (HTTP Status 500). – pholpar Apr 8 '15 at 12:47
  • i use fiddler and i get a 200 ok but a 500 response from the server – user3476614 Apr 8 '15 at 13:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.