Hi community, I have a Jira instance under
https://<instance>.atlassian.net/jira/
Everything is fine, and I would like to use REST API to, let say, creating an issue/bug automatically. Something like this: https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#creating-an-issue-examples
Looking at this example I see that it connects to localhost:8080 and use `-u charlie:charlie` (name and password - basic authentication).
Well, basic authentication is fine, but how should authentication work with my <instance>.atlassian.net ?
Can not find documentation/example about this, pls help...
Thanks in advance!
Hi @Manoj Gangwar is it correct that on Free Plan there are no restrictions on using REST API ? (I mean, it is the same as with another versions of JIRA)
Yes, you can use the REST API in Jira's free plan. the free plan provides access to the full functionality of the Jira REST API.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @D Welcome to the community!
Please refer to the below doc for Jira cloud.
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post
You can create the API token and use it as an authorization.
https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Manoj Gangwar , one more question:
Is it really necessary to specify ALL fields listed here:
https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post ?
Can I just specify summary, description and issuetype?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
No, you can specify only required fields which is required on your project at the time of issue creation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Manoj Gangwar would you pls help me one more time?
I can use JIRA REST API with curl, works great. Now I am doing the same in JS code running in browser. I am collecting some info from end-user in a form, when end-user press "Submit" than the following JS code should send it to JIRA to create a new bug:
```
try {
log.log('Sending request to JIRA API...');
const response = await fetch(JIRA_CONFIG.BASE_URL, {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${JIRA_CONFIG.USER}:${JIRA_CONFIG.TOKEN}`)}`,
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify(requestData)
});
...
} catch (error) {
log.log(`Error creating JIRA issue: ${error.message}`);
throw error;
}
```
And I get this error in browser console:
```
Sending request to JIRA API...
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://<instance>.atlassian.net/rest/api/2/issue/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 204.
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://<instance>.atlassian.net/rest/api/2/issue/. (Reason: CORS request did not succeed). Status code: (null).
Error creating JIRA issue: NetworkError when attempting to fetch resource.
```
Something goes wrong here... I think: if it works with curl - it should work with JS, isn't it? I would avoid using additional libs for this, I think the modern JS can handle this.
anyway, thanks in advance for your support!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Switch to Jira Cloud with Atlassian University! Explore new navigation, issue views, and Cloud features like team-managed projects and automation. Tailored for Data Center users & admins, these courses ensure a smooth transition. Start your journey today!
Enroll now
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.