Sharepoint 2010 Windows 8 app CRUD operations -
i in process of developing windows 8 (windows store) app connects sharepoint site using rest interface. currently, have managed pull down list data _vti_bin/listdata.svc/ uri. however, stuck on creating new list items within app, , posting these sharepoint.
i trying use http post method, receiving 405 error code: methodnotallowed. below code:
httpclienthandler clienthandler = new httpclienthandler(); clienthandler.usedefaultcredentials = true; httpclient newclient = new httpclient(clienthandler); // httpresponsemessage response = newclient.postasync("http://sharepoint/.../_vti_bin/listdata.svc/nominations", test); var resp = await newclient.getasync(newuri("http://sharepoint/.../_vti_bin/listdata.svc/nominations")); using (newclient) using (var ms = new memorystream()) { var djs = new datacontractjsonserializer(typeof(nominationsitem)); djs.writeobject(ms, test); ms.position = 0; var sc = new streamcontent(ms); sc.headers.contenttype = new system.net.http.headers.mediatypeheadervalue("application/json"); resp = test == null ? await newclient.putasync(new uri("http://sharepoint/.../_vti_bin/listdata.svc/nominations"), sc) : await newclient.postasync(new uri("http://sharepoint.../_vti_bin/listdata.svc/nominations"), sc); resp.ensuresuccessstatuscode(); } any appreciated!
Comments
Post a Comment