Redirected from DekiScript/Reference/Wiki Functions and Variables/Wiki.Api
Was this page helpful?

Wiki.Api

    Table of contents
    1. 1. Usage Restrictions
    2. 2. Parameters
    3. 3. Result
    4. 4. Samples
    wiki.api(source : uri) : xml

    Get an XML document from the API using the current user's credentials.

    Usage Restrictions

    9.02 or later.

    Parameters

    Name Type Description
    source uri XML source uri

    Result

    The document in xml format

    Samples

       Output

    SAMPLE1:

    {{ xml.format(wiki.api(uri.build(site.api, ['pages', 'popular'], {limit:1})), nil) }} 
    <pages.popular count="1" href="http://developer.mindtouch.com/@api/deki/pages/popular"> <page id="31084" revision="36" href="http://developer.mindtouch.com/@api/deki/pages/31084?redirects=0"> <uri.ui>http://developer.mindtouch.com/en</uri.ui> <title>MindTouch Community Portal</title> <path type="custom">en</path> <namespace>main</namespace> <language> </language> <metrics> <metric.views>19388</metric.views> </metrics> </page> </pages.popular>

     

      

    Was this page helpful?
    Tag page
    Viewing 5 of 5 comments: view all
    Should Wiki.api break and return an error when nothing is found? For instance:
    wiki.api(uri.build(page.api,"comments",{limit:15,sortby:"-date.posted",depth:"infinity"}))
    will return this error when no comments are found:
    /content/body/pre, function 'wiki.api' failed (click for details)
    MindTouch.Deki.Script.DekiScriptInvokeException: function 'wiki.api' failed ---> System.Exception: (unable to fetch text document from uri [status: 500 (InternalError)])
    at MindTouch.Deki.DekiWikiService.WikiApi (MindTouch.Dream.XUri source) [0x00000]
    at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&)
    at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000]
    --- End of inner exception stack trace ---
    at MindTouch.Deki.Script.DekiScriptRuntime+<Invoke>d__0.MoveNext () [0x00000]
    at MindTouch.Dream.Coroutine.Iterate_Helper (IEnumerator`1 coroutine, MindTouch.Dream.TaskBehavior behavior) [0x00000]
    at System.VoidClosure`2[System.Collections.Generic.IEnumerator`1[MindTouch.Dream.IYield],MindTouch.Dream.TaskBehavior].Closure () [0x00000]
    at MindTouch.Dream.Task.Execute (System.VoidHandler handler, MindTouch.Dream.TaskBehavior behavior) [0x00000]

    Bug filed: http://bugs.developer.mindtouch.com/view.php?id=6755 edited 18:51, 2 Jul 2009
    Posted 18:45, 2 Jul 2009
    @blakeh thanks for filing that. I already assigned it to myself. Will get addressed by Minneopa release.
    Posted 19:55, 7 Jul 2009
    Ok, the issue is that URI that was built was causing an internal server error (see [status: 500 (InternalError)]). So the problem wasn't with wiki.api itself, but with the API it was invoking. Either way, I just checked in a fix for it.
    Posted 12:51, 16 Jul 2009
    I'm getting the following error in my search results. I have a private wiki which I'm guessing is why it isn't working correctly. Should this be a bug?

    /content/body/pre, function 'wiki.api' failed (click for details)MindTouch.Deki.Script.DekiScriptInvokeException: function 'wiki.api' failed Server stack trace: at MindTouch.Deki.Script.DekiScriptRuntime+<Invoke>d__0.MoveNext () [0x00000] at MindTouch.Dream.Coroutine.Iterate (IEnumerator`1 coroutine, MindTouch.Tasking.TaskEnv env, System.Action`1 completion) [0x00000] Exception rethrown at [0]: ---> System.Exception: (unable to fetch text document from uri [status: 401 (Unauthorized)]
    Posted 07:55, 24 Feb 2010
    @chlupa the only situation where I can see that happen is if you're trying to fetch a document for User A that is not accessible to User A. By default, wiki.api passes in the credentials of the current user. So even if your site is private, wiki.api will still work. However, if the resource you're trying to access is indeed not available to the current user, then you will end up with an error message (and not a nice one at that!). I'm going to file a bug report on this. It should be possible to gracefully handle it.
    Posted 18:13, 24 Feb 2010
    Viewing 5 of 5 comments: view all
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by