Python: how to update Owner, FirstName, and Priority for BUG

16 views
Skip to first unread message

sunny changediya

unread,
Oct 26, 2016, 11:11:22 PM10/26/16
to DevTargetProcess
Team,

I am adding a new Bug into TargetProcess using Python requests. I am able to add & update "Name, Description" of Bug using following code.

import requests
headers = {'Content-Type' : 'application/json'}
payload = { 'Name' : 'Bug Test1' , 'Description' : 'Hello there.' }
r = requests.post(url, headers=headers, json=payload)
>> r.status_code
200

But when I tried to Update Owner & Timestamp, it gives me HTTP 404, BAD Request Error.

I tried to update using various combinations but got same error.

payload = { 'Id' : '5334' , 'Owner' : 'user-test.' }  | payload = { 'Id' : '5334' , 'Owner.FirstName' : 'user-test.' } | payload = { 'Id' : '5334' , 'Owner[FirstName]' : 'user-test.' } |
payload = { 'Id' : '5334' , 'Owner.FirstName' : 'user-test.' }

r = requests.post(url, headers=headers, json=payload)
>> r.status_code
404
>> r.reason
Bad request

tsar...@targetprocess.com

unread,
Nov 10, 2016, 7:25:00 AM11/10/16
to DevTargetProcess
Hello!

Just in case you still need the answer. Try the following:

import requests
headers
= {'Content-Type' : 'application/json'}

payload
= { 'Name' : 'Bug Test1' , 'Description' : 'Hello there.', 'Owner: { \'id\': 1 }' }

r
= requests.post(url, headers=headers, json=payload)

Id of the owner can be acquired with users API endpoint:

your_tp_url/api/v1/users

If you need a new user, your should create one and use his Id.
Reply all
Reply to author
Forward
0 new messages