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

Confluence Cloud API - 403

Christoph Reg Aug 23, 2017

I'm having trouble with using the AP.request method in the Javascript client.

I have created a Plugin which shows a custom page (general page) inside Jira.

From this page, I want to create a Confluence content page via the AP.request method of the Javascript client.

Working with the JIRA API via AP.request works fine, but when I try to call any method of the Confluence API it always fails with 403, no matter the endpoint I'm using.

Here is an example request that fails:

 

const data = {
          title: "test",
          "type": "page",
          "space": {
            "key": 'REL',
          },
          "body": {
            "storage":{
              "value": "<p>TEST TEST</p>",
              "representation": "storage",
            },
          },
};

AP.request({
        type: 'PUT',
        contentType: 'application/json',
        url: '/wiki/rest/api/content',
        data: JSON.stringify(data),
        success: (resp) => {
          console.log(resp);
        },
        error: (xhr, status, err) => {
          console.log(status);
        },
      });

What am I doing wrong here?

Do I need to specifically request a scope for Confluence in the addon descriptor?

Do I need to enable something in the settings?

1 answer

0 votes
Shannon Spaniol Atlassian Team Aug 24, 2017

Hi Christoph,

  1. Can you check and see if when you login to the instance using the same credentials can you add or modify a page in that space? 
  2. Does the space REL already exist? Since you're using the method PUT it only works to update and not create. Otherwise, you'll want to use POST. See our API documentation here:
    Create content: POST /rest/api/content

Kind Regards,
Shannon

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Confluence

6 Awesome Ways to Apply Trello, JIRA and Confluence to your Project

I attended  Atlassian Summit 2019  and learned a lot from the presenters, attendees and knowledgeable Atlassian product managers. The presentations I attended focused on applying Agile, pla...

1,125 views 7 18
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