BAMBOO task to use Token based authentication in the CURL script to create JIRA ticket
Asked by Devendar Gangapuram:

Hi Team,

I want to create JIRA ticket using the below **CRL** script by executing form Bamboo task. When we using basic authentication credentials in curl like below, it is creating JIRA ticket fine.

**Basic Authentication script, this is working fine.**

curl -D- -u abcd:test1234 -X POST --data "{\\"fields\\":{\\"project\\": {\\"key\\": \\"HELLOWS\\" }, \\"summary\\": \\"${bamboo.planName} - ${bamboo.buildNumber}\\", \\"customfield_11601\\": \\"${bamboo.planKey}-${bamboo.buildNumber}\\", \\"customfield_11600\\": \\"${bamboo.proj.pom.releaseVersion}\\n\\", \\"description\\": \\"Link to the build:\\n${bamboo.resultsUrl}\\n Link to UAT Deployment logs:\\n <https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments> \\n Link to PROD Deployment logs:\\n <https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments> \\n \\",\\"issuetype\\": {\\"name\\": \\"Task\\"}}}" -H "Content-Type: application/json" -k <https://jira-uat.appD.appZ.com/rest/api/2/issue/>

**Output**: I can see JIRA new ticket created.

**But , when I am trying to use Token based authentication in the CURL script, it gives bad substitution error and it is taking other JIRA project key(AUTJT), where I actually trying to create for the JIRA project key "HELLOWS".**

**CURL Script is:-**

curl -D- -u "Authorization: Bearer +ZZx2sJona6Cqeo37KjfvRv" -X POST --data "{\\"fields\\":{\\"project\\": {\\"key\\": \\"HELLOWS\\" }, \\"summary\\": \\"${bamboo.planName} - ${bamboo.buildNumber}\\", \\"customfield_11601\\": \\"${bamboo.planKey}-${bamboo.buildNumber}\\", \\"customfield_11600\\": \\"${bamboo.proj.pom.releaseVersion}\\n\\", \\"description\\": \\"Link to the build:\\n${bamboo.resultsUrl}\\n Link to UAT Deployment logs:\\n  
<https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments>  
\\n Link to PROD Deployment logs:\\n  
<https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments>  
\\n \\",\\"issuetype\\": {\\"name\\": \\"Task\\"}}}" -H "Content-Type: application/json" -k  
<https://jira-uat.appD.appZ.com/rest/api/2/issue/>

<br />

**output:**   
/bamboo/application-data/temp/RT-AUTJT-JOB1-35-ScriptBuildTask-6485507220746562543.sh: line 1: {"fields":{"project": {"key": "HELLOWS" }, "summary": "Retail Transformation - AutoJIRATicketPlan - 35", "customfield_11601": "RT-AUTJT-35", "customfield_11600": "${bamboo.proj.pom.releaseVersion}\\n", "description": "Link to the build:\\n  
[https://bamboo-uat.appD.appZ.com/browse/RT-AUTJT-JOB1-35\\](https://bamboo-uat.appD.appZ.com/browse/RT-AUTJT-JOB1-35\)n  
Link to UAT Deployment logs:\\n  
<https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSUAT/deployments>  
\\n Link to PROD Deployment logs:\\n  
<https://bamboo-uat.appD.appZ.com/browse/RT-HELLOWSPROD/deployments>  
\\n ","issuetype": {"name": "Task"}}}: **bad substitution**

Now, please help me, how to create the JIRA ticket using the token based authentication in the CURL, and also, form where it is referring the other project key?

Thanks,

Dev G


Answers:
author: Shashank Kumar
body: Hello Dev G,

Welcome to Atlassian community

I think you are using **-u**for both user_id password \& PAT token based authentication, the API will not differ based on what authentication type you are choosing.

For using PAT Tokens you can use an example like this, refer [PAT Tokens](https://confluence.atlassian.com/bamboo/personal-access-tokens-976779873.html)

    curl -H "Authorization: Bearer NDc4NDkyNDg3ODE3OstHYSeYC1UgXqRacSqvUbookcZk" http://localhost:8085/bamboo/rest/api/latest/plan/PROJ-PLAN 

Regards,

Shashank Kumar

**\*\*please don't forget to Accept the answer if your query was answered\*\***


Tags: api

curl

jira-soft

task

ticket