I have a document library,say People, with a custom content type (MyCustomType) with fields Location, Cost .This library has a folder say X . X has a subfolder Y. Y has 3 subfolders z1,z2,z3 at the same level.
I want to update the Location and Cost field for the folders X,Y,Z1,Z2,Z3 using REST in a C# console application. The examples I see on the net use CSOM. Can someone show the way to do this in C#.
The code I currently have is
Uri uri=new Uri("http://siteurl/People/X) ;//updating the folder X's properties first
HttpWebRequest re=(HttpWebRequest) WebRequest.Create(uri);
re.Credentials=CredentialCache.DefaultNetworkCredentials;
re.Method="POST";
re.Accept="application/json;odata=verbose";
re.Headers.Add("IF-MATCH","*");
re.Headers.Add("X-RequestDigest",GetFormDigest());
string data="{'__metadata':{'type':'SP.Folder'},'Location':"xyz'}";
re.ContentLength=data.length;
StreamWriter wr=new StreamWriter(re.GetRequestStream());
wr.write(data);
wr.Flush();
WebResponse rs=re.GetResponse();
using (StreamReader sr=new StreamReader(rs.GetResponseStream())
{
string result=st.ReadToEnd();
}
Pls ignore any typos. When I run above code, I get "bad request".