How to create new issue with text custom field in youtrack api?

412 views Asked by At

i have troubles with creating issue, writing text custom field. Here is my request. It works.

result = requests.post(
    url+'/api/issues', 
    headers={
        'Accept': 'application/json', 
        'Authorization': bearer_token
    },
    json={
        'project':{'id': self.project_youtrack},
        'summary': self.name,
        'description': self.description,
    }
)

by i didn`t find working example on documentation, how to add custom text field. I have field "Source" with id "87-18", It has type "text".

how can i create issue with this field filled?

1

There are 1 answers

0
Liubov Dievskaia On BEST ANSWER

You can find an example how to create an issue and set a custom field here: https://www.jetbrains.com/help/youtrack/devportal/resource-api-issues.html#create-Issue-method-sample

In that example, the custom field is not a text one, but an enum. For your case, the part of the payload with the custom fields would be:

"customFields": [
    {
        "value": {
            "text": "Text value"
        },
        "id": "<TextIssueCustomFieldID>",
        "$type": "TextIssueCustomField"
    }
]

Here you can see the attributes of the TextIssueCustomField entity: https://www.jetbrains.com/help/youtrack/devportal/api-entity-TextIssueCustomField.html