Re: [Trac] Set Version "Default" via API

Jun Omae <[email protected]> Sun, 19 Jan 2025 13:13:41 +0900
Newsgroups gmane.comp.version-control.subversion.trac.general
Message-ID <[email protected]>
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
>     {
>     "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 <[email protected]> (大前 潤)

-- 
Jun Omae <[email protected]> (大前 潤)

-- 
You received this message because you are subscribed to the Google Groups "Trac Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to trac-users+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
To view this discussion visit https://groups.google.com/d/msgid/trac-users/191a5cc7-9da2-4eb3-a633-0d3a4cdc2aa6%40gmail.com.