Announcement

Collapse
No announcement yet.

HTTP API question

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • HTTP API question

    Hello

    I've done a quick hack to integrate ox calendar functions in a rcp. It's just a query for 'my' appointments on a specific day.
    It works fine.

    But now i need the calendar informations from an other user for some kind of "free & busy". I can't find how to do this through the wiki doc.
    May be I'm just blind but please help me out.

    best regards

  • #2
    Ok, I have a look at the source and i found the action "freebusy" in the calendar module.
    Url example:
    /ajax/calendar?action=freebusy?id=<user/resourceId>?type=<Participant.USER(1) || Participant.RESOURCE(3)>?start=<start date>?end=<end date>

    Tow questions on this:
    1. Am I on the right way?
    2. If so, how can i get the userId effectively? I have a user login at my side.

    I'll document it in the wiki, but it would be great to have some feedback from the developer.

    Comment


    • #3
      I think you're on the right track. I've dug around a bit and resolving a username is a bit complicated.

      To resolve a username you use the contact module and do a "search" (or a "all" ) in the contact folder with the id 6. The folder 6 contains all contacts that correspond to internal users. Now when you request field 524 you'll be awarded with the internal user id, add 500 (display_name) for good measure, and you're good. Something like the following should give you all internal users:

      http://localhost/ajax/contacts?actio...sion=replaceMe

      Comment


      • #4
        Originally posted by Rondrian View Post
        Ok, I have a look at the source and i found the action "freebusy" in the calendar module.
        Url example:
        /ajax/calendar?action=freebusy?id=<user/resourceId>?type=<Participant.USER(1) || Participant.RESOURCE(3)>?start=<start date>?end=<end date>

        Tow questions on this:
        1. Am I on the right way?
        Yes.
        Originally posted by Rondrian View Post
        2. If so, how can i get the userId effectively? I have a user login at my side.
        See the modules "groups" and "resource". Also, the folder with the ID 6 contains all internal users. The field "internal_userid" (column ID 524) of those contacts contains the user ID, too.

        Comment


        • #5
          thx for the reply :-)

          Originally posted by Francisco Laguna View Post
          I think you're on the right track. I've dug around a bit and resolving a username is a bit complicated.

          To resolve a username you use the contact module and do a "search" (or a "all" ) in the contact folder with the id 6. The folder 6 contains all contacts that correspond to internal users. Now when you request field 524 you'll be awarded with the internal user id, add 500 (display_name) for good measure, and you're good. Something like the following should give you all internal users:

          http://localhost/ajax/contacts?actio...sion=replaceMe
          That's exactly the information i need (folderid=6 etc)

          I'll do the wiki stuff in the evening

          Comment


          • #6
            I've done the wiki stuff. Please have a look at it.

            One additional question:
            the response is an array of objects like this

            {"data":[
            {"shown_as":1,"end_date":1172620800000,"start_date ":1172534400000,"id":23,"full_time":true}, {"shown_as":1,"end_date":1172620800000,"start_date ":1172534400000,"id":49,"full_time":true},
            {"shown_as":1,"end_date":1172577600000,"start_date ":1172566800000,"id":45}
            ],
            "timestamp":0}

            as you can see the "full_time" property is only present if true.
            This is hard to convert. Should it be like this, or is this a bug?

            Comment


            • #7
              Excellent, thanks for updating the wiki.

              As for the weird full_time property. Per specification in the Wiki (you just wrote), this is to be expected ;-) Jokes aside: I see how this can be tedious, and I hope we can get the designers of this interface to comment on it.

              Aside from that:
              What language are you writing your client in? Do you write the parsing for these answers yourself or do you use a JSON library? I'd definitely recommend the latter, as it will save you a lot of headaches. http://www.json.org has a few suggestions for libraries.

              Comment


              • #8
                I'm writing it in Java for use in RCP.
                And of course I'm using Json-lib.

                I've written a query like solution, where I can map to my beans.

                I can map your columns to my bean properties and json properties to my bean properties.
                I use something like this:
                JSONObject jsonOb = JSONObject.fromString(responseStr);
                jsonOb.get("jsonproperty");

                But this get method throws an exception if its not present. So I have to implement a special way just for free and busy.

                But it's just at the beginning.
                Is there a place to submit the source and discuss it. It's a private project for the small company of my mother.
                I'd like to publish it under the Apache license, if there is some interest.

                Comment


                • #9
                  Just another question:

                  is it possibly to post a full list or property file of cloumn to property name to the wiki? I'm thinking of something like this:
                  1=id
                  2=created_by
                  3=modified_by
                  4=creation_date
                  5=last_modified
                  20=folder_id


                  I've done this for my short beginning by hand, but this is stupid work.
                  So if you have such a list please post it. Otherwise I'll collect it and post it in the wiki. But step by step.

                  Comment


                  • #10
                    It's already in the wiki: Common Object Data, Detailed Task And Appointment Data, etc.

                    Comment


                    • #11
                      Yes, I know.
                      But I need it in good an simple format for parsing as config in my client. So a property file or csv file.
                      If you have such a file it would be great to have it.
                      If not, no problem, I will collect one and post it, because i think it is useful for everyone writing a client.

                      Comment


                      • #12
                        Originally posted by Rondrian View Post
                        I'm writing it in Java for use in RCP.
                        And of course I'm using Json-lib.

                        I've written a query like solution, where I can map to my beans.

                        I can map your columns to my bean properties and json properties to my bean properties.
                        I use something like this:
                        JSONObject jsonOb = JSONObject.fromString(responseStr);
                        jsonOb.get("jsonproperty");

                        But this get method throws an exception if its not present. So I have to implement a special way just for free and busy.
                        Maybe it'd be a good idea to use the 'opt' method instead of 'get'. If the json-lib is anything like the library we use, 'opt' won't throw an exception, and just give you a null.

                        Originally posted by Rondrian View Post
                        But it's just at the beginning.
                        Is there a place to submit the source and discuss it. It's a private project for the small company of my mother.
                        I'd like to publish it under the Apache license, if there is some interest.
                        We had a system for that once. Why not simply create a wikipage for it? We can later refactor it to some general advice or an example of how to use the Ajax Interface. Or we go on here with the help of the forums and pastebin and friends.

                        Comment


                        • #13
                          Yes, thanks for the hint, I'm using 'opt' now and do some standard transformation through commons-beans (needed for timestamp transformation to calendar)
                          so null -> false

                          more updates next week... maybe a first preview at the end of next week

                          Comment


                          • #14
                            Its much later than tow weeks but its not forgotten ;-)

                            I have some legal questions and i want to know were i can ask them best?
                            The questions are that kind of Open-Xhange is a trademarke a it will get the TM in all my documentation. But waht about Hyperion, is it a trademark, too?

                            So questions like these.

                            Can someone of the OX guys please post the best email-address for such kind of questions

                            Comment

                            Working...
                            X