Announcement

Collapse
No announcement yet.

How to add categories programmatically?

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

  • How to add categories programmatically?

    Hi OX hackers,

    I would like to add categories (with colors) via a computer program. For this I investigated the HTTP API. As far as I understand the documentation there is not proper API for this. From debugging the webclient I learned that categories are set via "PUT /ajax/config/gui" containing a string such as {"categories":{"local":[{"color":5,"name":"Private"},{"color":2,"name":"Bu siness"}]}.

    So my question is: Is calling the "PUT /ajax/config/gui" url the right place to add categories (with colors)? Is it sufficient to add just the categories string or must other content be provided in order to not change anything else?

    Thanks for your feedback.

    Best regards,
    Thomas

  • #2
    As far as the HTTP API is concerned, all categories are just comma-separated strings in field 100 of each object. The assignment of colors is done purely by the GUI, and the set of defined categories is stored in the GUI-specific configuration of each user, as you already found out.

    The entire GUI configuration is stored as one big JSON object, so if the users already logged in and may have made changes to their configuration, then you have to first retrieve it with a GET request, parse the JSON object, make the modifications you need, and then upload the modified JSON object with a PUT request. You can do this either via the HTTP API or using command line tools.

    When provisioning new users, there is no JSON object to parse, so you can just upload a new object containing only the "categories" field.

    Comment


    • #3
      Thank you very much for your detailed answer! This was exactly I was looking for!

      Thomas

      Comment

      Working...
      X