Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can Jira REST API error messages *not* be localized / translated?

Ronan March 21, 2019

Jira REST API (v2 or v3, Server and Cloud) error messages are localized, based on the locale of the user associated to the request.

For example, getting a non-existent task when authenticated with credentials using a Chinese locale will return an HTTP 400, with in the response an error message ID 为“10002”的值在域 “project”中不存在。 (which Google translates to The value with ID "10002" does not exist in the domain "project).

Is there a way to not have these error messages localized? I found that the v2 platform docs / Get locale mentions in a slightly different context that Jira responds to an accept-language header. So I tried setting the header to en_US, without success.

Is it feasible? Or is it feasible to get Jira to respond with an additional originalErrorMessage response key containing the un-translated English string? Does a bug / feature request exist or can one be filed?


My use case, for context: I'm totally okay to localize UI, of course! But for API error message it feels like a strange choice. I'm working on automating things in Jira using the API and, to correctly handle errors, the HTTP error code sometimes isn't enough, so I have to do things like if (error.message.includes('not found')) {.... Which obviously breaks down if said error message is translated 😕.

2 answers

1 accepted

1 vote
Answer accepted
Parth June 22, 2022

You need to use special headers 

 

 

(To get error messages in Spanish) Pass:

X-Force-Accept-Language: true

Accept-Language: es 

 

(To get error messages in French) Pass:

X-Force-Accept-Language: true

Accept-Language: fr

 

 

By default, the header Accept-Language is ignored unless you pass X-Force-Accept-Language. This should result in error messages from API appear in your desired language 

 

**captain flies away drinking a pop**

Ronan June 22, 2022

Aweeeeeeeesome, thanks Parth!!!

On a sad note, I see that X-Force-Accept-Language is only supported by Jira Cloud. The latest (8.22.4) Jira Server docs, section "Special request and response headers", don't list this header.

Jira Server is on the death row, I know, but there are lots of customers still using it, so it'd be great if this feature was backported to it, I would enjoy it a lot.

So, asking Andy in the reply below (or any other Atlassian) to consider a backport.

0 votes
Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 26, 2019

Hi Ronan,

Thanks for explaining your use case here.  I think I better understand what you are seeing here and why it would be helpful to force such error messages to a single language.

I was not able to find any existing requests for this functionality.  I suspect that these responses are intended to be readable by the person making them, so the end user's locale is important in regards to them being able to clearly understand the response they get back.   But I can see in your use case where it would be helpful to have some kind of flag or key to pass an API request that could return the REST response in a specific language. 

So I created a feature request for this over in JRACLOUD-71793

Just so you know, the ability to create suggestion type issues in the JRACLOUD project is something that you can do yourself as well.  

I hope this helps.

Andy

Ronan June 22, 2022

Hey Andy.

As mentioned by Parth in the above answer, this is now supported by Jira Cloud's X-Force-Accept-Language header. So, feel free to close JRACLOUD-71793.

*But* on a sad note, I see that X-Force-Accept-Language is only supported by Jira Cloud. The latest (8.22.4) Jira Server docs, section "Special request and response headers", don't list this header.

Jira Server is on the death row, I know, but there are lots of customers still using it, so it'd be great if this feature was backported to it, I would enjoy it a lot.

Could you create a ticket asking for it? Thank you.

Andy Heinzer
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 5, 2022

I created a corresponding request for Jira Server/Data Center over in https://jira.atlassian.com/browse/JRASERVER-74088

Thanks for updating the jracloud ticket and this thread with the updated info.

Like Ronan likes this

Suggest an answer

Log in or Sign up to answer