Request Jira REST API wiht Basic Auth doesn't work anymore

I can’t request issues using basic auth.
After googling and testing for hours, i need some help here.

OK:
curl -D- -u 'email:pwd' -X GET -H 'Content-Type: application/json' https://**dev.atlassian.net**/rest/api/2/issue/TEST-1

curl -D- -u 'email:pwd' -X GET -H 'Content-Type: application/json' https://**devSecond.atlassian.net**/rest/api/2/issue/TEST-1

NOT OK:

curl -D- -u 'email:pwd' -X GET -H 'Content-Type: application/json' https://**myInstance.jira.com**/rest/api/2/issue/TEST-1

curl -D- -X GET -H "Authorization: Basic <encodedUsername:Pwd>" -H "Content-Type: application/json" https://**myInstance.jira.com**/rest/api/2/issue/JIRA-123

curl -D- -X GET -H "Authorization: Basic <encodedEmail:Pwd>" -H "Content-Type: application/json" https://**myInstance.jira.com**/rest/api/2/issue/JIRA-123

Response:

HTTP/1.1 401 Unauthorized
Server: nginx
Date: Mon, 15 May 2017 12:06:21 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-AREQUESTID: 846x40994x9
X-Seraph-LoginReason: OUT
X-Seraph-LoginReason: AUTHENTICATED_FAILED
WWW-Authenticate: **OAuth** realm="https%3A%2F%2Fmyinstance.jira.com"
X-Content-Type-Options: nosniff
Set-Cookie: JSESSIONID=92B37EF8FF512345ABFBD8385A9E9E99; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=""; Domain=.myinstance.jira.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly
Set-Cookie: studio.crowd.tokenkey=""; Domain=.myinstance.jira.com; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; Secure; HttpOnly

I don’t know why response-header variable is WWW-Authenticate: **OAuth** and not Basic as specified.

Also appending url parameter os_authType=basic has no effect at all.
I did my testing with terminal and postman rest client.

Thank you for support

Testet:

https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/

Hi @developers,

If your JIRA Cloud instance has been migrated to Atlassian account, you need to use your Atlassian account email address and password. This should work whether encoded in a header or not. If you don’t know whether your instance has been migrated or what your password is, you can verify this and reset your password from your “My Profile” page in JIRA Cloud.

Hi @dmeyer

Thank you for your reply.

As you may have seen in the ‘NOT OK’ section that’s what i’ve already tried.
I’ve tried all public documented combination.

Of course it’s a migrated account but i can use both logins. So i know both valid credentials for my instance users.

So what else can be the problem ?
Why does the response-header contains: WWW-Authenticate: OAuth ?

Regards

Hi @developers

Can you try encoding your Atlassian account email address:password combination as a single value? So that if your email was example@atlassian.com and your password was password the request would look like

curl -D- -X GET -H "authorization: Basic ZXhhbXBsZUBhdGxhc3NpYW4uY29tOnBhc3N3b3Jk" https://example.atlassian.net/rest/api/2/issue/DEMO-1

Hi @dmeyer

I’ve done this as well - base64-encoded(Username:Pwd) or base64-encoded(Email:Pwd). May be my command-example was a bit misleading.

It should be:
curl -D- -X GET -H "Authorization: Basic <encoded(Username:Pwd)>" -H "Content-Type: application/json" https://**myInstance.jira.com**/rest/api/2/issue/JIRA-123

and:

curl -D- -X GET -H "Authorization: Basic <encoded(Email:Pwd)>" -H "Content-Type: application/json" https://**myInstance.jira.com**/rest/api/2/issue/JIRA-123

What else could it be ?

Regards

Hi @dmeyer , the problem still exists and i need some support because our app can’t connect anymore to jira using rest api.

Thank you

Just pointing to this related question: Jira cloud REST API no longer accepting basic authorisation.

1 Like

@david.pinn thank you.
I find one workaround here https://jira.atlassian.com/browse/JRACLOUD-66793 but this is not working with our migrated JIRA Cloud instance to Atlassian account.

I’ve tried with username:password and email:password encoeded or decoded.
Is there a bug for migrated JIRA Cloud instance to Atlassian accounts ?

@developers I recommend creating a support request with Atlassian support, they can look at the situation with you specific instance.

Hi All,

i am using

curl -D- -u XXXX/XXXX -X POST --data-binary “/tmp/test.txt” -H “Content-Type: application/json” http://XXX.atlassian.net/rest/api/2/issue/

and getting below error .

HTTP/1.1 400 Bad Request
Server: Atlassian Proxy/0.1.140
ATL-vTM-Backend-Time: 592
Cache-Control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Strict-Transport-Security: max-age=315360000; includeSubDomains; preload
Date: Thu, 02 Nov 2017 10:39:33 GMT
X-AREQUESTID: 05a2396b-d134-4862-a1cd-6b8262118f0b
transfer-encoding: chunked
ATL-vTM-Time: 772
X-AUSERNAME: XXXX
X-Content-Type-Options: nosniff
Connection: close
Set-Cookie: atlassian.xsrf.token=BZL8-4THC-ZN65-UK3O|337a0ae0237ef7ca653a3dc7474fb421a2be95f8|lin; Path=/; Secure
X-Seraph-LoginReason: OK
ATL-vTM-Queue-Time: 0

{“errorMessages”:[“Unexpected character (’/’ (code 47)): maybe a (non-standard) comment? (not recognized as one since Feature ‘ALLOW_COMMENTS’ not enabled for parser)\n at [Source: org.apache.catalina.connector.CoyoteInputStream@a1715e8; line: 1, column: 2]”]}

while the data input file is in format.

{
“fields”: {
“project”:
{
“key”: “KEY”
},
“summary”: “TEST EXAMPLE”,
“description”: “Creating an issue via REST API”,
“issuetype”: {
“name”: “Bug”
}
}
}

Can anyone suggest/help.

Hi, @bharat.

This means that the format of your command is incorrect.

–data-binary “/tmp/test.txt”

This should not start with a ‘/’. Kindly check this article as I think it has a good explanation of what happened and how to solve it.

Cheers!
Ian

1 Like

Thanks @iragudo for your support it resolved the issue.