Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

unable to use api

mati skiba
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 6, 2018

Hello,

 

I am using Jira under ravmesser.atlassian.net and trying to use the api to pull and process data from a website, but still unable to do so.

 

I have tried in a few ways:

- tried using the connector, by including https://ravmesser.atlassian.net/atlassian-connect/all-debug.js
When the page loads I get the following errors:
all-debug.js:3174 Uncaught TypeError: Cannot read property 'sizeToParent' of undefined
at all-debug.js:3174
at all-debug.js:3247
(anonymous) @ all-debug.js:3174
(anonymous) @ all-debug.js:3247
(index):37 Uncaught TypeError: Cannot read property 'require' of undefined
at (index):37

- tried performing an api call from the browser where I am logged in to ravmesser.atlassian.net
Browsed to the following url: https://jira.atlassian.com/rest/api/2/project

- tried performing an api call using basic authentication
Create key string, then accessed https://jira.atlassian.com/rest/api/2/project via Postman with the credentials. Got Unauthorized response. The same when I attempted curl request.

 

Could anyone help me connect to the api?

Kind regards,

Mati Skiba

3 answers

1 vote
Fernando Bordallo July 8, 2018

Hello @mati skiba! Welcome to the community.

Did you follow the 'atlas-connect' tutorial (https://developer.atlassian.com/cloud/jira/platform/build-a-jira-app-using-a-framework/) on your way to this situation or did you put your own auth system in place?

If you put together your own, would you mind sharing some of your code (jsBin or code pen of some sort) to get a better look at what can be happening.

0 votes
Fernando Bordallo July 9, 2018

Hello again @mati skiba!

Here is a little example of a node app (can be replicated easily on your website if you want) following the Basic Auth guide (https://developer.atlassian.com/cloud/jira/platform/jira-rest-api-basic-authentication/):

https://github.com/ferborva/jira-basic-api

 

This is the part you will be interested in comparing with your code:

...
// Atlassian API token - Obtained from id.atlassian.net // My username - complete email. ie. xxxx@domain.com // Atlassian domain where my Jira Cloud instance lives. ie. <domain>.atlassian.net const token = process.env.API_TOKEN; const username = process.env.USERNAME; const domain = process.env.DOMAIN; const encoded = btoa(username+':'+token) // console.log(encoded) // == Fetch from the Jira Cloud projects API endpoint == fetch(`https://${domain}.atlassian.net/rest/api/2/project`, { headers: { 'Authorization': `Basic ${encoded}` } }, ....

If you have any more doubts let me know or you can open a issue in the repo. 👍

0 votes
mati skiba
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 8, 2018

Hello @Fernando Bordallo, thank you for you answer.

The tutorial is not relevant for me. I am not trying to create a Jira app, but simply to access the Jira API through a website (only client side, no server side code). Can you direct me in how to do it?

Kind regards,

Mati

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 9, 2018

You are already trying to do it the right way, but it seems your authentication is failing.  That means you are doing that incorrectly, and need to fix that.  Looking for access in other ways isn't going to help.

What are you doing differently to what the documentation says about doing basic authentication?

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events