java - Upload document with metadata / Update document itself - Sharepoint 2010 Rest API -


i need upload documents on sharepoint foundation 2010 in java ee project (spring mvc). i'm using httpclient interact sharepoint 2010 rest api, working have 2 questions :

  • how can upload document metadata ? moment, upload document , update metadata after upload's complete. because of method document automatically in version 2.0, it's not optimal behavior...
  • how can update document ? know how update metadata have no ideas update document itself.

my upload :

    defaulthttpclient httpclient = new defaulthttpclient();     ntcredentials credentials = new ntcredentials(this.username, this.password, "", "");     httpclient.getcredentialsprovider().setcredentials(authscope.any, credentials);      string url = "[url library api - ..../listdata.svc/library]";     string slug = "[url document]";      httppost post = new httppost(url);     post.getparams().setbooleanparameter(coreprotocolpnames.use_expect_continue, false);     post.setheader("content-type", "multipart/form-data");     post.setheader("accept", "application/json; charset=utf-8; odata=verbose");     post.setheader("slug", slug);      multipartentity multipartcontent = new multipartentity(httpmultipartmode.browser_compatible);     multipartcontent.addpart(file.getname(), new filebody(file));     post.setentity(multipartcontent);      httpresponse response = httpclient.execute(post); 

my metadata's update :

    defaulthttpclient httpclient = new defaulthttpclient();     ntcredentials credentials = new ntcredentials(this.username, this.password, "", "");     httpclient.getcredentialsprovider().setcredentials(authscope.any, credentials);      string url = "[url document api - ....listdata.svc/library(id)]";      httppost post = new httppost(url);     post.setheader("content-type", "application/json");     post.setheader("accept", "application/json; charset=utf-8; odata=verbose");     post.setheader("x-http-method", "merge");     post.setheader("if-match", etag);      post.setentity(new stringentity("[json update metadata]", contenttype.application_json));      httpresponse response = httpclient.execute(post); 


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -