Forums

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

REST API auth error

BayWa IT Workplace Atlassian
February 6, 2020

Hi Community,

 

we´re building simple Python scripts for JIRA using the REST API with Basic auth (this way is ok for us, no need for Oauth at the moment).

For building the correct codes we´re using SOAP UI before we implement it in our scripts.

 

When we start execution, for example GET on https://jira.ourdomain.com/rest/api/2/applicationrole we see an error 401 Unauthorized (401). After some tries we get an error 403 and CAPTCHA is active for this user .

So it´s seems that data was correct and the username can be extracted from base64 encoded string by JIRA (base64 string is username:password).

In the past this way worked fine.

 

The same credentials (base64) work perfect in Confluence with REST API, so it seems to be a problem on JIRA side. In the backend both systems use Crowd with the same user directory (LDAP).

We´re using JIRA 8.6.1 with reverse proxy and activated SSL.

 

Regards

Uli

15 answers

1 accepted

1 vote
Answer accepted
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 21, 2012

Could be leaked connections or a deadlock somewhere. Please take a stack trace as documented in http://confluence.atlassian.com/display/JIRA/Generating+a+Thread+Dump and post it here

 
1 vote
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 20, 2012
Have you ever thought of writing this in JQL like here: https://answers.atlassian.com/questions/24285/executing-a-jql-string-in-plugin-and-getting-result-issues ? To me this sees a lot more maintainable because you can write the query in one line without using ids and you can even get the total number of issues using searchResults.getTotalCount(). no need to loop through the issues.

More important even: by using Jql you avoid database access since Jql search use the Lucene Index only. This won't use any of your database connections.

i know i don't give a. answer that helps you out immediately but please consider using Jql if it's acceptable from a performance point of view

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 22, 2012

I'll double check when I can, but I know this works for me... what jira version?

0 votes
DOT-COMmunications
Contributor
April 22, 2012

Atlassian JIRA (v4.4.4#664-r167664)

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 22, 2012

Strange... this definitely works for me. Did you select the "number" template or some other?

0 votes
DOT-COMmunications
Contributor
April 22, 2012

I set it to use the number template and the number searcher for the field.

0 votes
DOT-COMmunications
Contributor
April 22, 2012

@Jamie

No i do not see it in issue navigator but it does show up fine when viewing the issue itself.

Issue Navigator

Image above is from issue navigator

Image below is from the issue view

Issue View

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 22, 2012

As I asked you on the other place, do you see the value in the issue navigator when you add the column to the output?

0 votes
DOT-COMmunications
Contributor
April 22, 2012

@Jamie - That appears to be working okay but will keep an eye on JIRA and the logs for any problems.

I have updated to 2.0.4 but when i try showing the column on a filter result on the dashboard the column is just empty, any ideas?

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 21, 2012

OK, just remove the conn.close line. I would reindex and look for errors in the logs.

0 votes
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 21, 2012
Sorry, for my answer. I didn't see the part ' AND issue = '${it.issue} in the where condition of Jamies solitiom on my iPad. Today i can see that, really don't know what happened yesterday. For this reason i have deleted my answer though it still seems problematic to have such deeply nested loops.
0 votes
DOT-COMmunications
Contributor
April 21, 2012

Thanks for your help anyway @Dieter, it probably is a problem having such deep loops but not sure of any other way to do it. It is adapted from a PHP & mySQL query that i run on the database itself to produce an e-mail report but i am wanting to display the data inside JIRA so thought i could just adapt the query.

@Jamie - Thank you for the code but i keep getting this error in the logs when trying it:

/plugins/servlet/com.onresolve.ScriptedFieldPreviewServlet [onresolve.jira.groovy.GroovyCustomField] javax.script.ScriptException: java.sql.SQLException: Connection is closed.

It happens when it gets to the finally block on the conn.close() statement

0 votes
DOT-COMmunications
Contributor
April 21, 2012

We have about 5 users at the moment. I dont think it is a JIRA deadlock though as now that i have taken the field out it has not stopped responding once.

@Dieter/Jamie - Probably could do in JQL but i need a count of records rather than a list of records if that is possible without writing a custom plugin to do it?

@Dieter - sqlStmt2 returns a set of issue records than the inital statement, what it is doing is checking that the custom field applies to the correct record (summary and sClient match) but returns a set of issues from the customfieldvalue table instead so that i can iterate over them in the next SQL statement.

@Jamie - Thank you for the code i will take a look at it and get back to you about if it works etc.

0 votes
Norman Abramovitz
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 21, 2012

How many users do you have? I would first try increasing the number of connections. Also I would contact support since it sounds like Jira might have a deadlock issue given that other people are starting to complain about running out of connections as well.

0 votes
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Champions.
April 20, 2012

I agree with Dieter, if it's possible to do it in JQL then I would use that. Is it? If so we could give an example for using JQL.

If not, I would write it like this: https://gist.github.com/2438750 (not tested).

I'm not sure about closing the connection, the javadoc implies that closing the Sql object should close the connection. Perhaps for some issues it's failing, so you're never getting to the code for closing stuff. Check the logs for errors.

> We are wanting to display the result of this field on a dashboard (Filter result gadget) but the value shows up blank on the dashboard and fine in the issue view

Can you try 2.0.4, I seem to remember a previous version was missing the column-view.vm template.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events