Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,297,449
Community Members
 
Community Events
165
Community Groups

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

Edited

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

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**

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 Mar 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

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you