PDA

View Full Version : Can't Plug to User Page with C#



scottro
03-30-2011, 03:44 PM
We are using the DReAM API to auto-generate content from an XML document. Our code works when we upload to the /Drafts page or the top of the tree. But we can't get it to work with "/User:" pages.

What is the proper way to specify pages in the /User: space?

The documenation is not elaborate:
http://developer.mindtouch.com/en/ref/MindTouch_API/POST%3apages%2f%2f%7Bpageid%7D%2f%2fcontents

We tried using both "/User:Auser" and "User:Auser" by replacing MindTouchSubdirectoryPath in the code snippet below, but were unsuccessful.

mindTouchPlug.At("pages", "=" + MindTouchSubdirectoryPath + "%252f" + xmlDoc.ObjectName, "contents")

The API is invoked by Auser - authenticated with that user's id/password.

Thanks!
-Scott

arnec
03-30-2011, 07:00 PM
The tricky bit is this:

or "=" followed by a double uri-encoded page title

This works for me:

var plug = Plug.New("http://developer.mindtouch.com/@api/deki").At("pages", "=" + XUri.DoubleEncodeSegment("User:arnec"), "contents");

scottro
03-30-2011, 07:50 PM
Yes, particularly since the example in the doc doesn't spell out the use of XUri.DoubleEncodeSegment(). We'll try it.

Thanks very much Arne!
-Scott

scottro
03-31-2011, 04:08 PM
We used the following (names changed to protect the innocent):

mindTouchPlug.At("pages", "=" + XUri.DoubleEncodeSegment("User:" + MindtouchUserName) + "%252f" + MindTouchSubdirectoryPath + "%252f" + xmlDoc.ObjectName, "contents")

arnec
03-31-2011, 04:17 PM
MindTouchSubdirectoryPath might still need double-encoding itself. This should be safer:



mindTouchPlug.At(
"pages",
"=" + XUri.DoubleEncodeSegment("User:" + MindtouchUserName + "/" + MindTouchSubdirectoryPath + "/" + xmlDoc.ObjectName),
"contents
);

scottro
03-31-2011, 04:28 PM
Very good. Thanks for tightening the bolts!