Re: Roundup rest API

"John P. Rouillard" <[email protected]>
Newsgroups gmane.comp.bug-tracking.roundup.user
Message-ID <[email protected]>
Hello Norbert:

In message <[email protected]>,
SCHLEMMER Norbert writes:
>Where can I find an "How-to" add a keyword / list of keywords to an issue ?

There isn't a How-To for that, but the info needed is in the rest
guide.  You are looking for the example that has the string:
rest/data/issue/@poe/viz in it.


To expand a little. To create a new item (status, issue, user etc.)
you POST a json data structure to the item endpoint:
tracker/rest/data/status for example.

To find out the json structure, perform a GET with ?@verbose=0
(described in the section "Using the POST method") on a similar
item. For example on my customized tracker:

a GET to: tracker/rest/data/status/8?@verbose=0 produces.

{
    "data": {
        "id": "8",
        "type": "status",
        "link": "tracker/rest/data/status/8",
        "attributes": {
            "abbreviation": "D",
            "help": "Ticket has been closed. Will not be worked on.",
            "name": "dead",
            "order": 8,
            "requiredpermissions": null,
            "transitions": [
                "1",
                "2",
                "4"
            ]
        },
        "@etag": "\"a1974134dfc8410fc46163032f063c0d\""
    }
}

The attributes json blob is what you want to replicate to create a new
status.  (Note this is from my tracker. It has attributes like
"abbreviation" and "transitions" yours will be different.)

To create a new status, I created the file /tmp/new_status.json with
this content:

 {
            "abbreviation": "Z",
            "help": "example status created via rest. Do not use.",
            "name": "zoid",
            "order": 11,
            "requiredpermissions": null,
            "transitions": []
        }


and submitted it using:

    curl -u admin:adminpassword -X POST \
    --data-binary @/tmp/new_status.json \
    -H "x-requested-with: rest" \
    -H "Content-Type: application/json" \
    -H "Origin: https://hostname" \
    -H "Referer: https://hostname/tracker" \
     https://hostname/tracker/rest/data/status

and got the result:

{
    "data": {
        "id": "10",
        "link": "https://hostname/tracker/rest/data/status/10"
    }
}

The x-requested-with and Content-Type headers are required. You may
not need all the rest of the header fields. I have all the cross site
request forgery protections engaged, so I need them.

The user can be any user who has create privs for the status
item. Usually this is anybody with the Admin role and usually only the
admin account has that role. You can see if another role has that
ability by running:

  roundup-admin  -i demo security | sed -ne '/^Role/p' -e '/create status/p'
  Role "admin":
  Role "agent":
  Role "anonymous":
  Role "provisional user":
  Role "seeabout":
  Role "seeaboutprivdetails":
  Role "setanystatus":
  Role "user":

So we can see that no other role has the ability to create a
status. (Note that the Admin role has the right to make CRUD operations
on all items. Security doesn't list every item for Admin. It prints
"User may create everything" instead.)

Does this help?

Have a great rest of the week.

--
				-- rouilj
John Rouillard
===========================================================================
My employers don't acknowledge my existence much less my opinions.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.