Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,552,979
Community Members
 
Community Events
184
Community Groups

Regarding REST API

Hello Members,

i'm trying following CURL and getting. Please suggest

{"message":"Client must be authenticated to access this resource.","status-code":401}

###

curl --request GET \
--url 'https://domain.atlassian.net/rest/servicedeskapi/request/10026' \
--header 'Authorization: Bearer <access token>' \
--header 'Accept: application/json'

3 answers

2 accepted

0 votes
Answer accepted

After lot of troubleshooting have following API working

1. To GET Access code

 

curl -X POST \
  --header 'Content-Type: application/json' \
  --data '{
            "grant_type": "client_credentials",
            "audience":"api.atlassian.com",
            "client_id": "<Client_id>",
            "client_secret": "<Client_Secret>"
          }'
2. To GET Accessible Resources(Need to give necessary Granular permissions in Developer Console
curl --request GET \
--url 'https://api.atlassian.com/oauth/token/accessible-resources' \
--header 'Authorization: Bearer <Access code received from 1st CURL>' \
--header 'Accept: application/json'
3. to GET Project details
curl --request GET \
  --url 'https://api.atlassian.com/ex/jira/{Cloud_id received from 2nd CURL}/rest/api/3/project/10002' \
  --header 'Authorization: Bearer <>' \
  --header 'Accept: application/json'

4. Create an issue in JIRA
curl --request POST \
  --url 'https://api.atlassian.com/ex/jira/{Cloud_id received from 2nd CURL}/rest/api/3/issue' \
 --header 'Authorization: Bearer  <Access code received from 1st CURL>' \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
   --data '{
    
        "fields": {

        "summary": "Issue creation via REST API ",

        "issuetype": {

            "id": "10008"

        },

        "project": {

            "id": "10002"

        },

        "description": {

            "type": "doc",

            "version": 1,

            "content": [

                {

                "type": "paragraph",

                "content": [

                    {

                    "text": "REST API in JIRA are not straight forward.",

                    "type": "text"

                    }

                ]

                }

            ]

        }

    }
   
}'
Karim ABO HASHISH
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

hi @Ravi Chaganti 

Exactly. Glad it worked for you.

If you think my answer was helpful, thanks to mark it as accepted, so it would help other users looking for similar functionality.

Cheers,

Karim

0 votes
Answer accepted
Karim ABO HASHISH
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 09, 2023

hi @Ravi Chaganti 


For Outh 2.0 you will need to enable and configure it through the developer console to create application access with some extra steps to enable your client.

The steps are well explained in the below link

Setting and Configuring OAuth 2.0 (3LO) apps

Cheers,

Karim

Thank you for taking time and responding @Karim ABO HASHISH

I've configured per instructions mentioned above and trying the CURL command.

I'm getting Access Token for below CURL command

 

Content-Type: application/json 

{
            "grant_type""client_credentials",
            "audience":"api.atlassian.com",
            "client_id""XXXXXXXX",
            "client_secret""XXXXXX",
            
}

i'm trying to create an issue. I'm looking for correct end-point for

  • issue creation
  • getting issue details of the issue created.

curl --request POST \
--url 'https://api.atlassian.com/ex/jira/{cloud id}/rest/api/3/issue/' \
--header 'Authorization: Bearer  <Access code>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{

"fields": {

"summary": "JL - Test",

"issuetype": {

"id": "10008"

},

"project": {

"id": "10002"

},

"description": {

"type": "doc",

"version": 1,

"content": [

{

"type": "paragraph",

"content": [

{

"text": "This is the description.",

"type": "text"

}

]

}

]

}

}

}'

0 votes
Karim ABO HASHISH
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 08, 2023

hi @Ravi Chaganti 

You need to use basic authentication and create an API token using this link to use it as your password.

Example below using CURL


curl -D- -u $NAME:$PASSWORD -X GET -H "Content-Type: application/json" https://domain.atlassian.net/rest/servicedeskapi/request/10026



Another Example using Postman

L0dlo7vZYH.png

Good Luck and let us know how it went for you

Cheers,

Karim

Thank you Karim for reply.

i'm working with OAuth enabled REST API as part of organization's requirement.

This was the reason i'm sending Bearer and Access code in Header.

Any suggestion on OAuth enabled REST API will help

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events