when trying to post via the youtrack api (adding a issue) I get a problematic error.
Here is my code:
`postHeaders = {
'Accept':'application/json',
'Authorization':'secret',
'Content-Type':'application/json'
}
postData = {
'project':{'id':'0-5'},
'summary':'sample',
'description':'Sample description'
}
responsePost = requests.post("https://yourcompany.youtrack.cloud/api/issues", headers=postHeaders, data=postData)
print(responsePost.content)`
I got this error:
b'{"error":"bad_request","error_description":"Unrecognized token \'project\': was expecting (JSON String, Number, Array, Object or token \'null\', \'true\' or \'false\')\\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 9]"}'
Can You guys help.
I tried formatting in various ways JSON format I changed ' to ' but nothing would work. the result is to add a issue to the project with id 0-5
Maybe this dumping to json will support?
import json
postData = {
'project': {'id': '0-5'},
'summary': 'sample',
'description': 'Sample description'
}
# Convert the dictionary to a JSON string
postData_json = json.dumps(postData)
print(postData_json)