Forums

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

Im new to jira and trying to call the api but it is giving me error and also im using Custom UI

Taha Husnain
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!
August 2, 2024

useEffect(() => {

    const url = `https://${jiraDomain}/rest/api/3/issue/KAN-1`;
    const getIssue = async () => {
      try {
        const res = axios.get(url, {
          headers: {
            Authorization: `Bearer ${apiToken}`,
            Accept: "application/json",
          },
        });
        console.log("respone ===>", res);
        setText(res);
      } catch (error) {
        console.log(error.message);
      }
    };
    getIssue();
  }, [jiraDomain, email, apiToken]);

1 answer

0 votes
Trudy Claspill
Community Champion
August 2, 2024

Hello @Taha Husnain 

Welcome to the Atlassian community.

What is the error you get?

Taha Husnain
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!
August 3, 2024

First Issue:

I'm encountering a CSP violation detected for 'script-src' while serving content at http://localhost:8000/. The error message suggests that for an app to share data with external resources or use a custom CSP, I should follow the steps in this guide: Atlassian Forge Content Security and Egress Controls. This error is occurring on the front-end side.

Second Issue:

I am receiving an error: "Uncaught Error: Unable to establish a connection with the Custom UI bridge."

Third Issue:

When trying to access XMLHttpRequest at 'https://hayloo.atlassian.net/rest/api/2/issue/KAN-1' from origin 'https://localhost:3000', I am blocked by a CORS policy. The error states: "Response to preflight request doesn't pass access control check: It does not have HTTP ok status."

What is the proper way to call the Jira issue API or any API? I created a Jira project with a custom UI, and these are all the errors I'm encountering. I've tried using a proxy and the methods provided by Jira, but have been unsuccessful. Could you please guide me and suggest a solution?


MY YAML FILE

modules:
  jira:projectPage:
    - key: hello-world-hello-world-project-page
      resource: main
      resolver:
        function: resolver
      title: hello-world
  function:
    - key: resolver
      handler: index.handler
resources:
  - key: main
    path: static/hello-world/build
    tunnel:
      port: 3000
permissions:
  scopes:
    - read:jira-work
  content:
    styles:
      - "unsafe-inline"
app:
  runtime:
    name: nodejs18.x
  id: ari:cloud:ecosystem::app/61f3883e-3d83-4702-b6c8-2728884b9d0a
Trudy Claspill
Community Champion
August 5, 2024

Hello @Taha Husnain 

Unfortunately your issues are outside my realm of experience. I asked you for the error information because without that nobody would be able to suggest what you would need to do to fix your issues.

Are you using the Forge platform for this development? If so there is a Forge developer community that might have the expertise to help you.

https://community.developer.atlassian.com/

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events