Forum Discussion

venuj1244's avatar
venuj1244
Contributor
12 years ago

Can anybody provide the code sample to call restAPI's from endpoint

  • From within an endpoint, we typically use restadmin:

     

    <#assign message = restadmin("/messages/id/${mid}").message />

     

    You can also use rest() if you want.

     

    To call the endpoint, we would do something like this (from within jQuery):

     

    $.ajax({
            type: "GET",
            url: "/company/plugins/custom/company/company/our_endpoint",
            data: ({
                    "mid":"${mid}",
                    "xslt":"json.xsl"
            })

    });

     

    The URL for the endpoint can be found when you're defining it.  We set the output format of all of our endpoints to be XML.  This way, we can transform it using JSON if we need to.

  • From within an endpoint, we typically use restadmin:

     

    <#assign message = restadmin("/messages/id/${mid}").message />

     

    You can also use rest() if you want.

     

    To call the endpoint, we would do something like this (from within jQuery):

     

    $.ajax({
            type: "GET",
            url: "/company/plugins/custom/company/company/our_endpoint",
            data: ({
                    "mid":"${mid}",
                    "xslt":"json.xsl"
            })

    });

     

    The URL for the endpoint can be found when you're defining it.  We set the output format of all of our endpoints to be XML.  This way, we can transform it using JSON if we need to.

    • venuj1244's avatar
      venuj1244
      Contributor

      Hi,

       

       

      Thanks for the solution you have provided to me. it helps me a lot.

       

      Can you please confirm me Is there any way  i can get the forum posts in ascending or descending order ?

       

       

      Regards

      Venu J

      • xorrkaz's avatar
        xorrkaz
        Genius

        Have a look at /boards/id/BID/messages/linear.  This will give you the messages in a given board.  You can use the message_viewer.topic_sort_order query argument to control sorting.  There's also /boards/id/BID/threads/recent that may be of use to you. This will list the most recent thread in chronological order.  You can go back to the beginning of time using the appropriate page_size and page count.