Authentication is performed and a file property is created named "myprop". Using the batch property update feature, "myprop" is updated with a new value with the current value's etag. A non existent property "propertyToDelete" is attempted to be deleted by not specifying a new content value.
Plug p = Plug.New("http://devwiki/@api/deki");
p.At("users", "authenticate").WithCredentials("sysop", "password").Get();
XDoc myPropResponse = p.At("files", "42", "properties") .WithHeader("Slug", "myprop")
.Post(DreamMessage.Ok(MimeType.TEXT_UTF8, "initial value")).AsDocument();
XDoc body = new XDoc("properties");
body.Start("property").Attr("name", "myprop").Attr("etag", myPropResponse["/property/@etag"].AsText)
.Start("contents").Attr("type", "text/plain").Value("new value for property").End()
.Elem("description", "description of change")
.End();
body.Start("property").Attr("name", "propertyToDelete").End();
XDoc response = p.At("files", "42", "properties")
.Put(body).AsDocument();
<properties count="1" href="http://devwiki/@api/deki/files/42/properties">
<property name="myprop" href="http://devwiki/@api/deki/files/42/properties/myprop/info" etag="4465.r2_ts2009-03-20T23:52:50Z">
<contents type="text/plain" href="http://devwiki/@api/deki/files/42/properties/myprop">new value for property</contents>
<date.modified>2009-03-20T23:52:50Z</date.modified>
<user.modified id="1" href="http://devwiki/@api/deki/users/1">
<nick>Sysop</nick>
<username>Sysop</username>
</user.modified>
<change-description>description of change</change-description>
<status code="200" />
</property>
<property name="propertyToDelete">
<status code="400">
<error>
<status>400</status>
<title>Bad Request</title>
<message>The property 'propertyToDelete' does not exist and cannot be deleted.</message>
<uri>http://devwiki/@api/deki/files/42/properties</uri>
</error>
</status>
</property>
</properties>
Add notes about requirements or config values
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by