Hello,
I have a c++ program that uses nlohman json to parse and construct json data and curl to construct HTTP requests. My goal is to read a task, make a status transition via POST method and add something in the comment. Both the task reading and comment writing work on shell and in program. I was able to work out the shell command for transitioning the task:
curl.exe --user bla.bla@blabla.com:xxxxxxxxx -X POST -H "Content-Type: application/json" -d '{""transition"": {""id"": ""51""}}' https://bla1234.atlassian.net/rest/api/3/issue/AS-10/transitions?expand=transitions.fieldsWhich works perfectly. I implemented then the same thing in c++ with curl and that's where the strange things happens. When trying to update I often get HTTP 400 and 500 errors. Continue trying and eventually the post is accepted (see image1). I tried basically to replace every character in my string, at the moment the header and the json are generated like that:
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Accept-Encoding: identity");
headers = curl_slist_append(headers, "Content-Encoding: identity");
headers = curl_slist_append(headers, "Content-Type: application/json; charset=UTF-8");
headers = curl_slist_append(headers, "Accept-Charset: utf-8");
.
.
.
transition = "51";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "{\"transition\": {\"id\": \"" + transition + "\"}}")
Apparently adding encoding mitigated a little the problem, however the number of errors before it gets accepted are completely random. Sometimes no error at all sometimes 20 attempts.
Someone an idea?
