Forums

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

Basic Authentication header

Bhagavan Goud
Contributor
July 17, 2022

While trying to create a Jira project Using Post Method with REST API URL getting user doesn't have access.

How to get the Access_token.

1 answer

1 vote
Kishan Sharma
Community Champion
July 18, 2022

Hi @Bhagavan Goud 

Firstly, you will need to create an API token from your Atlassian account:

  1. Log in to https://id.atlassian.com/manage-profile/security/api-tokens.

  2. Click Create API token.

  3. From the dialog that appears, enter a memorable and concise Label for your token and click Create.

Then follow Basic auth for REST APIs for examples on how you can use it in scripts. Hope this helps. 

Bhagavan Goud
Contributor
July 18, 2022

Hi, @Kishan Sharma  Thank you for the information.

While trying with like above one getting 500 Internal Server Error

 

function createProject(keyValue,summary,lead,issueUrl)
{
var originalKeyValue = keyValue;
keyValue = keyValue.replace("-","");
console.log(keyValue);
summary = summary.trim();
console.log(summary);

AJS.$.ajax
({
url: urlToAPI[baseUrl],
type: "POST",
timeout: 0,
dataType: 'json',
processData: false,
headers: {
"Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic YmhhZ2F2YW4uZ291ZEBpbi5lYm1wYXBzdC5jb206RWJtUGFwc3RJbml0aWFsLWI3KXY=="
// "Authorization" : "Basic " + btoa(lead + ":" + "")
},
data: JSON.stringify({
"key": keyValue,
"name": originalKeyValue+" "+summary,
"lead": lead,
"url": issueUrl,
"projectTypeKey": "business",
"templateProjectId":global_config_project_template_id
//"templateProjectId":"13303"
}),
success: function (response) {
console.log(JSON.stringify(response));
console.log("keyValue"+response.key);
alert("Jira project has been created. Now you will be navigated to the project summary screen.");
window.location.replace(((baseUrl=='http://localhost:2990')?(baseUrl+'/jira'):(baseUrl)) +'/projects/'+ keyValue +'/summary');
},

Vikrant Yadav
Community Champion
July 18, 2022

@Bhagavan Goud  Do you have JIRA Admin permission, as per the error message it seems that you don't have project creation access ? 

Bhagavan Goud
Contributor
July 18, 2022

Hi @Vikrant Yadav  I have JIRA Admin Permission but the error message seems that you don't have project creation access? 

Vikrant Yadav
Community Champion
July 18, 2022

@Bhagavan Goud  Are you able to create project manually from front end ? 

Kishan Sharma
Community Champion
July 18, 2022

Hi @Bhagavan Goud are you able to create a project manually from the UI ? 

Bhagavan Goud
Contributor
July 18, 2022

Hi @Kishan Sharma, and @Vikrant Yadav  Yes

Kishan Sharma
Community Champion
July 18, 2022

Hi @Bhagavan Goud From the error it looks like either the parameters are incorrect or that the json package is incorrect.  Please see the KB Get an internal server error message when trying to create a new issue through REST method

You can refer example here and make sure you are using the correct headers, payload, and endpoint with parameters.

Vikrant Yadav
Community Champion
July 18, 2022

Hi @Bhagavan Goud  Are you using JIRA cloud or local host JIRA server ? 

If you using JIRA Cloud you can check this link for creating project via Rest API :-  https://www.youtube.com/watch?v=jrYbx-3Px9A

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events