Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Set Version "Default" via API

21 views
Skip to first unread message

Greg H

unread,
Jan 13, 2025, 3:10:12 PMJan 13
to Trac Users
Anyone know how to set a version as "Default" (the default version for new tickets) when creating or updating a version via XmlRpc API? There are ticket.version.create and ticket.version.update methods that accept 'attributes' so I'm guessing something can be passed in here to achieve this?

Jun Omae

unread,
Jan 18, 2025, 4:01:52 PMJan 18
to trac-...@googlegroups.com
Hi,

On 2025/01/14 0:16, Greg H wrote:
> Anyone know how to set a version as "Default" (the default version for new tickets) when creating or updating a version via XmlRpc API? There are ticket.version.create and ticket.version.update methods that accept 'attributes' so I'm guessing something can be passed in here to achieve this?

Try to omit "version" in the attributes parameter after setting default to one of versions in Manage Versions page.

[[[
$ cat body.json
{
"id": 42,
"method": "ticket.create",
"params": [
"summary",
"description",
{
"type": "task",
"priority": "minor"
}
]
}

$ curl -s -u admin:password -H "Content-Type: application/json" \
--data @body.json \
http://192.168.11.122:3000/tracenv/login/rpc
{"result": 3, "error": null, "id": 42}

$ curl -s -u admin:password -H "Content-Type: application/json" \
--data '{"method": "ticket.get", "params": [3]}' \
http://192.168.11.122:3000/tracenv/login/rpc | jq -M
{
"result": [
3,
{
"__jsonclass__": [
"datetime",
"2025-01-18T20:48:52.485867"
]
},
{
"__jsonclass__": [
"datetime",
"2025-01-18T20:48:52.485867"
]
},
{
"summary": "summary",
"reporter": "admin",
"owner": "< default >",
"description": "description",
"type": "task",
"status": "new",
"priority": "minor",
"milestone": "",
"component": "",
"version": "2.0", # <== The default version is used
"resolution": "",
"keywords": "",
"cc": "",
"time": {
"__jsonclass__": [
"datetime",
"2025-01-18T20:48:52.485867"
]
},
"changetime": {
"__jsonclass__": [
"datetime",
"2025-01-18T20:48:52.485867"
]
},
"_ts": "1737233332485867"
}
],
"error": null,
"id": null
}
]]]

--
Jun Omae <jun...@gmail.com> (大前 潤)

Greg H

unread,
Jan 18, 2025, 9:38:39 PMJan 18
to Trac Users
Sorry for the confusion. The "default to one of versions in Manage Versions page" is what I am trying to automate. I have a process to automatically generate versions via API, but we need to still manually mark them as "Default" instead of setting via API.

Jun Omae

unread,
Jan 18, 2025, 11:13:54 PMJan 18
to trac-...@googlegroups.com
It is unable to set the default version of new ticket in Trac RPC.

Because it is need to set [ticket] default_version in trac.ini to
configure the default version of new ticket, but no method to
configure trac.ini in Trac RPC exists.

On 2025/01/19 6:12, Greg H wrote:
> Sorry for the confusion. The "default to one of versions in Manage Versions page" is what I am trying to automate. I have a process to automatically generate versions via API, but we need to still manually mark them as "Default" instead of setting via API.
>
> On Saturday, January 18, 2025 at 4:01:52 PM UTC-5 Jun Omae wrote:
>
> Hi,
>
> On 2025/01/14 0:16, Greg H wrote:
> > Anyone know how to set a version as "Default" (the default version for new tickets) when creating or updating a version via XmlRpc API? There are ticket.version.create and ticket.version.update methods that accept 'attributes' so I'm guessing something can be passed in here to achieve this?
>
> Try to omit "version" in the attributes parameter after setting default to one of versions in Manage Versions page.
>
> [[[
> $ cat body.json
> {
> "id": 42,
> "method": "ticket.create",
> "params": [
> "summary",
> "description",
> {
> "type": "task",
> "priority": "minor"
> }
> ]
> }
>
> $ curl -s -u admin:password -H "Content-Type: application/json" \
> --data @body.json \
> http://192.168.11.122:3000/tracenv/login/rpc <http://192.168.11.122:3000/tracenv/login/rpc>
> {"result": 3, "error": null, "id": 42}
>
> $ curl -s -u admin:password -H "Content-Type: application/json" \
> --data '{"method": "ticket.get", "params": [3]}' \
> http://192.168.11.122:3000/tracenv/login/rpc <http://192.168.11.122:3000/tracenv/login/rpc> | jq -M
Reply all
Reply to author
Forward
0 new messages