Perform changes on multiple user properties
Name | Type | Description |
userid | string | either an integer user ID, "current", or "=" followed by a double uri-encoded user name |
Name | Type | Description |
authenticate | bool? | Force authentication for request (default: false) |
redirects | int? | If zero, do not follow page redirects. |
Name | Value | Description |
OK | 200 | The request completed successfully |
Bad Request | 400 | Invalid input parameter or request body |
Forbidden | 403 | ADMIN access is required to access other user's properties |
Not Found | 404 | Requested user could not be found |
Input is a list of property xml blocks. Only text values are allowed to be modified via this feature. To modify a non-text property value, use PUT: users/{userid}/properties/{key} instead. Properties are deleted if no contents node is provided. An etag is not required for deleting properties.
<properties> <property name="{text}" etag="{text}"> <contents type="{text}">{text}</contents> <change-description>{text}</change-description> </property> <property name="{text}"/> </properties>
Response is a list of the standard property xml blocks as well as any error blocks.
<properties count="{int}" href="{uri}"> <property name="{text}" href="{uri}" etag="{text}"> <contents type="{text}" href="{uri}">{text}</contents> <date.modified>{date}</date.modified> <user.modified id="{int}" href="{uri}"> <nick>{text}</nick> <username>{text}</username> </user.modified> <change-description>{text}</change-description> </property> <property name="{text}"> <status code="{int}"> <error> <status>{int}</status> <title>{text}</title> <message>{text}</message> <uri>{uri}</uri> </error> </status> </property> </properties>
Authentication is performed and a property for the current user 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("users", "current", "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("users", "current", "properties") .Put(body).AsDocument();
<properties count="1" href="http://devwiki/@api/deki/users/1/properties"> <property name="myprop" href="http://devwiki/@api/deki/users/1/properties/myprop/info" etag="4465.r2_ts2009-03-20T23:52:50Z"> <contents type="text/plain" href="http://devwiki/@api/deki/users/1/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/users/1/properties</uri> </error> </status> </property> </properties>
Add notes about requirements or config values.
The following command applies the properties listed in "properties.xml" to a user with user ID = 1.
curl -u admin:password -H "Content-Type: application/xml" -T properties.xml -i http://mindtouch.address/@api/deki/users/1/properties
ADMIN permission is required to execute above command. Otherwise, a 403 HTTP response (Forbidden) will be returned.
Batman happens to be an Expert user. We want to make changes to his properties. The following XML document adds a couple properties and removes the "alterego" property added in this example. Batman's user ID = 4.
Content-Type: application/xml
<properties> <!-- Add a couple properties --> <property name="location"> <contents type="text/plain">Gotham</contents> </property> <property name="transportation"> <contents type="text/plain">Batmobile</contents> </property> <!-- Remove a property, to do this omit contents element --> <property name="alterego"/> </properties>
curl -u admin:password -H "Content-Type: application/xml" -T batman.xml -i http://192.168.168.110/@api/deki/users/4/properties
HTTP/1.1 200 OK Date: Tue, 12 Jan 2010 23:51:20 GMT Server: Dream-HTTPAPI/1.7.2.17433 X-Deki-Site: id="default" Content-Type: application/xml; charset=utf-8 Content-Length: 2444 Via: 1.1 dekiwiki
Content-Type: application/xml
<?xml version="1.0"?> <properties count="3" href="http://192.168.168.110/@api/deki/users/4/properties"> <property name="location" href="http://192.168.168.110/@api/deki/users/4/properties/location/info" etag="37.r1_ts2010-01-12T23:51:20Z"> <contents type="text/plain" size="6" href="http://192.168.168.110/@api/deki/users/4/properties/location">Gotham</contents> <date.modified>2010-01-12T23:51:20Z</date.modified> <user.modified id="1" href="http://192.168.168.110/@api/deki/users/1"> <nick>Admin</nick> <username>Admin</username> <email>melder@mindtouch.com</email> <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email> <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar> </user.modified> <status code="200"/> </property> <property name="transportation" href="http://192.168.168.110/@api/deki/users/4/properties/transportation/info" etag="38.r1_ts2010-01-12T23:51:20Z"> <contents type="text/plain" size="9" href="http://192.168.168.110/@api/deki/users/4/properties/transportation">Batmobile</contents> <date.modified>2010-01-12T23:51:20Z</date.modified> <user.modified id="1" href="http://192.168.168.110/@api/deki/users/1"> <nick>Admin</nick> <username>Admin</username> <email>melder@mindtouch.com</email> <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email> <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar> </user.modified> <status code="200"/> </property> <property name="alterego" href="http://192.168.168.110/@api/deki/users/4/properties/alterego/info" etag="35.r2_ts2010-01-12T23:51:20Z"> <contents type="text/plain" size="11" href="http://192.168.168.110/@api/deki/users/4/properties/alterego">Bruce Wayne</contents> <date.modified>2010-01-12T23:51:20Z</date.modified> <user.modified id="1" href="http://192.168.168.110/@api/deki/users/1"> <nick>Admin</nick> <username>Admin</username> <email>melder@mindtouch.com</email> <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email> <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar> </user.modified> <user.deleted id="1" href="http://192.168.168.110/@api/deki/users/1"> <nick>Admin</nick> <username>Admin</username> <email>melder@mindtouch.com</email> <hash.email>637b79dca5c8ebdc4347bccca42d3487</hash.email> <uri.gravatar>http://www.gravatar.com/avatar/637b79dca5c8ebdc4347bccca42d3487</uri.gravatar> </user.deleted> <date.deleted>2010-01-12T23:51:20Z</date.deleted> <status code="200"/> </property> </properties>