Seting custom field in Youtrack Issue via API using Python
When i'm adding issue to YouTrack via Api using python (requests lib). everything works as expected. Code below:
postHeaders = {
'Accept':'application/json',
'Authorization':'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'Content-Type':'application/json'
}
postData = {
'project':{'id':'0-5'},
'summary':project_name,
'description':description,
responsePost = requests.post("https://myCompany.youtrack.cloud/api/issues", headers=postHeaders, data=postData_json)
print(responsePost.content)
Than i made a custom field in Youtrack lets call it important_number.
When i add
"customFields":[
{ "name":"important_number","$type":"SimpleIssueCustomField","value":{"name":'123'}},
]
to my postData, as Youtrack documentation says i got error:
{"error":"server_error","error_description":"Tried to set object to field of primitive type"}'
I'm sure that the $type and name is correct because i querry the YT for that info and paste it in code.
I have tried changig type for every other posible there is, but nothing seems to work.
Please sign in to leave a comment.
Hi!
I'm Sergey from the YouTrack team.
I suggest that you go step-by-step through this verbose approach first to find out the correct data type and values for your custom field. Additionally, you can create a new issue via a web interface and explore the browser's network records to see which request our frontend makes and then use it as an example for your case.
If you have any questions, please let me know.