Redirected from Deki/API Reference/POST:users/{userid}/properties/Curl Code Samples/Add User Property
Was this page helpful?

Add User Property

    Description of the code sample

    The following command adds a user property with property name "foo" and pairs it with the data from file "bar". The user name is "user".

    Sample Code

    curl -u username:password -H "Content-Type: text/plain" -H "Slug: foo" -d @bar -i http://mindtouch.address/@api/deki/users/=user/properties

    Implementation notes 

    curl flags

    -u
    Basic HTTP authentication. Sends a username and password to server so it can verify whether a user is of privilege to perform specific operation.
    -d @file
    Specifies a POST request and the data file to send.
    -H
    Replaces or appends an HTTP header. The "Slug" header designates the property name. The "Content-Type" header specifies the MIME type of the value attached to the property.
    -i
    Includes the HTTP response header in the output. Useful for debugging.

    MIMEs

    Properties can contain any type of file, therefore it is important to specify the correct MIME when creating a property. For instance, a text property will require a text/plain header, xml will require application/xml header, a jpeg image will require image/jpg header, and so on.

     

    Example

    We want to create a simple text property for the user Batman. The property name is "alterego" and the value is "Bruce Wayne", as outlined in "userprop.txt".

    userprop.txt

    Content-Type: text/plain

    Bruce Wayne

    Sample Code

    curl -u username:password -H "Content-Type: text/plain" -H "Slug: alterego" -d @userprop.txt -i http://192.168.168.110/@api/deki/users/=Batman/properties

    HTTP Response Headers

    HTTP/1.1 200 OK
    Date: Tue, 12 Jan 2010 01:10:45 GMT
    Server: Dream-HTTPAPI/1.7.2.17433
    X-Deki-Site: id="default"
    Content-Type: application/xml; charset=utf-8
    Content-Length: 680
    Via: 1.1 dekiwiki
    

    HTTP Response Body

    Content-Type: application/xml

    <?xml version="1.0"?>
    <property name="alterego" href="http://192.168.168.110/@api/deki/users/4/properties/alterego/info" etag="35.r1_ts2010-01-12T01:10:44Z">
      <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-12T01:10:44Z</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>
      <change-description/>
    </property>

    Notes

    • In order for properties to be displayed in "Page Properties" pages, the property name must be prefixed with "urn:custom.mindtouch.com#", otherwise it will remain hidden.
    • The easiest way to view properties if they do not appear in the UI is by accessing the XML file for the page properties. For example, the XML for the above path is <http://192.168.168.110/@api/deki/use...man/properties>.
    Was this page helpful?
    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by