简体   繁体   中英

QT and JIRA Rest API: /rest/api/2/issue/createmeta unexpectedly returns issuetype names in Korean

This is a weird one and I am stuck.

I am writing an application using C++ and the Qt framework that plugs in to jira via the rest API. I am just writing the first part which gets data on projects and issuetypes using /rest/api/2/issue/createmeta. I am testing my code against a cloud hosted JIRA Software instance.

However with my code the response I am getting back from /rest/api/2/issue/createmeta in the JSON has the issuetype names and descriptions in Korean. My instance is setup for English. Also the same transaction in Postman and in Chrome comes back correctly in English.

I am guessing that my HTTP headers are at fault, but I can't see what I am doing wrong. Here is a code fragment that fires off the transaction:

QNetworkRequest request;

m_restURL.clear();     // This is a QUrl used to hold the URL
m_restURL.setUrl(mp_jiraInstanceUrl + QString("/rest/api/2/issue/createmeta"));

request.setUrl(m_restURL);

// HTTP Basic authentication header value: base64(username:password)
QString concatenated = *mp_accountName + ":" + mp_password;
QByteArray data = concatenated.toLocal8Bit().toBase64();
QString headerData = "Basic " + data;
request.setRawHeader("Authorization", headerData.toLocal8Bit());

// Other header stuff
request.setRawHeader("X-Atlassian-Token", "nocheck");
request.setRawHeader("Content-Type", "application/json");

mp_reply = qnam.get(request);  // where qnam is previously setup as QNetworkAccessManager qnam;

Any help gratefully received as I am stumped. :)

I have found a work around but I am not sure this is the 'most correct' way of doing this.

I added the following line to the code in the "Other Header Stuff" section:

request.setRawHeader("accept-language", "en-GB,en-US;q=0.9,en;q=0.8,ko;q=0.7");

This seems to tell JIRA that I want responses in English and I am getting correct JSON back. However I am not still sure why my JIRA with its default language set to English would send responses in another language. Weird.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM