Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Creating issue in JIRA REST API?

I installed cURL and I'm trying to create a JIRA issue from the command line but the curl code that Atlassian uses as an example isn't working for me. Atlassian says to use this url in the curl code: " http://localhost:8090/rest/api/2/issue/"

I tried replacing "localhost:8090" with my companies JIRA domain and it still didn't work. Do I have to use "localhost:8090" and try it from the command line on my JIRA server?? I'm just confused how this is working. Thanks!

1 answer

0 votes

You have done the right thing, if your JIRA is running on http://mycompany.com/jira then you'd replace localhost:8090 with mycompany.com/jira

So, the question is what you mean by "isn't working".  What is the error message and what are you actually sending?

Hey,


This is the curl I'm inputting:
curl -k -D- -u fred:fred -X POST --data {"fields": {"project": ITAM{ "key": "TEST" }, "summary": "REST ye merry gentlemen.", "description": "Creating of an issue using project keys and issue type names using the REST API", "issuetype": { "name": "App:Unknown"}}} -H "Content-Type: application/json" http://jira.mycompany.com/rest/api/2/issue/


I got this straight from Atlassian here: https://developer.atlassian.com/jiradev/jira-apis/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-create-issue

 

jira.mycompany.com is how we access jira.


error messages:
Could not resolve host: key
Could not resolve host: RESTT ye merry gentlemen
Could not..... and so on


Thanks for the help

Ok, there's a couple of issues:

  1. the first couple of fields look wrong - the examples say "project key Test", but you've got "project ITAM { key test }"
  2. I think your error message is telling you that you are using "" on the command line and then inside the data you are sending as well - that can't work because a " is ending the data and the next part of the data is being taken as the next command for curl.  Try surrounding the data segment with ' marks to separate them out.

 

 

Oh that was a silly mistake with the project.. I switched "Test" to ITAM and took away the other ITAM. I also tried the ' marks but I'm getting the same error. When I try to access jira.mycompany.com/rest/api/2/issue/ in my browser I get an HTTP status 405 error "Method Not Allowed" and I should be getting some JSON. I feel like that might be the reason I'm getting the command line error. Thoughts?

Also, what's the "fred:fred" in the curl?

fred:fred is the username and password you want to perform the action as.

I've always found quotes annoying, and most of my REST stuff dodges it.  Put the JSON in a plaintext file (lets call it MyRestJson.txt), then instead of having to think about quotes etc, you can just go "curl ... --data @MyRestJson.txt ..." and it'll read the raw content from the file.

okay I took your advice and put everything in a file. That got rid of the of the could not resolve host and the other errors.. but I'm still getting an http 302 error. This is a redirect error.. would you happen to know anything about this?? Thanks for your help so far

okay I finally got it to work! thanks for your help!!

 

Oh, redirect errors - so close smile

Hi Shane, I am getting the same error as yours (302). How did you get it to work?

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

JSM June Challenge #2: Share how your business teams became ITSM rockstars

For JSM June Challenge #2, share how your non-technical teams like HR, legal, marketing, finance, and beyond started using Jira Service Management! Tell us: Did they ask to start using it or...

314 views 9 7
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you