Hey what's up everyone! Welcome to Red Stapler
again. This week's video video we will talk
about how to create an issue in JIRA
with API. To create an issue
You just need to make a POST request to
the REST endpoint URL and then specify
the issue information in JSON format
If the request succeeded you get a response
with the issue ID, issue keys and the
link to issue itself. I'm going to use a
Chrome extension (Postman) to test the
JIRA API. First i'm going to copy the link to the API
For the request, we need to set the header
content-type header to application/json
and for the authorization, we'll just use
the basic authorization (Authentication). Actually
you can use other authorization methods such as
Cookie authentication, but for this
tutorial we'll just go with Basic
Basic authentication is simply to encrypt your
username and password in base64 format
and add it to your HTTP header
Now in the body,
you just specify the issue information
such as issue key, summary, description,
issue type
It's the same as you created on the web
If i want to create a technical project
the issue keys is TP. The issue type is
task. But if you want to create other
type you can do that as well
Now if everything is ready I'm going to
submit the request. Now you can see that
our POST request succeeded and I got the
issue keys
TP-5 and a link to the issue so I'm going
to refresh the dashboard. You'll see that
our newly created ticket shows here
Now you may have a questions what should
I do if I'm going to create a web
application and use the JIRA API to create
an issue? I took a step to create a very
simple PHP to create an issue
You can submit the issue information you want to
create with the form
Now I have a simple form and the buttons and a JavaScript to
submit the form when we click the button
All the information will be passed through
jirapi.php
Inside the jiraapi.php, first of all I'm going to encode the
username and password with base64
format and then initiate the curl with
the REST API URL. I'm going to set the
returntransfer to true so I can get the
response from the JIRA. We set the post
request to true and set the HTTP
header with content-type application/json
and basic authentication and
these other steps to build the JSON
request and then make the actual request
execute the curl and return result
You can find this example code in the video
description box below. That's it!
Let me know if you have any questions any
feedback. Thanks for watching and don't
forget to subscribe :) Bye