I'm in the process of automating creating a JIRA project. I noticed when I use this cURL command from within a bash script I receive this error
Error:
{"errorMessages":[],"errors":{"projectKey":"Project keys must start with an uppercase letter, followed by one or more uppercase alphanumeric characters."}}
Command:
curl -u username -X POST https://jirainstance/rest/project-templates/1.0/createshared/${project_id} -H "Content-type: application/json" --data '{"key":"${Project_key^^}", "name":"${project_name}", "lead":"${project_lead}"}'
This only shows up when I use a variable in place of the key data. If I use this command with directly typing in the key data it works normally. Any ideas?
I had to encase the --data information in double quotes and escape the double quotes within it.
According to this link, variables are not expanded in singe quotes
curl -u username -X POST https://jirainstance/rest/project-templates/1.0/createshared/projectID -H "Content-type: application/json" --data "{\"key\":\"${newprojectname}\", \"name\":\"Double Quote Test\", \"lead\":\"username\"}"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The error says must start with uppercase, so are you actually using uppercase letters in the project key that is being fed into the command? variable substitution wouldn't really matter here. As long as the data being received and sent to the endpoint is correct, Jira will process the request and output a response.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your response.
I've tried using both upper and lowercase. Even still, I added ^^ to ensure the variables value will be all caps.
echo "Project Key"
read Project_key
echo ${Project_key^^}
is what I use and then pass Project_key to cURL.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I just ran a test to see if it was the variable and it seems that it is being taken literally.
curl -u username -X POST https://jirainstance/rest/project-templates/1.0/createshared/projectID -H "Content-type: application/json" --data '{"key":"BEST", "name":"${newprojectname}", "lead":"username"}'
I have the same echo/read commands prior to this curl command.
The project is created, but the name is "${newprojectname}" and not what is stored in the variable.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
okay, i think the data is not formatted properly.
curl -u username -X POST https://jirainstance/rest/project-templates/1.0/createshared/projectID -H "Content-type: application/json" --data '{"key":"BEST", "name":"'${newprojectname}'", "lead":"username"}'
you should add single quotes to the variable substitution, so it can actually detect it. Also when writing curl it's better to use an editor such as atom.io it will give you syntax highlight, so you can know what's wrong.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.