Confluence: PUT data from Configuration page

So I have an app working, but want to store a couple simple values from a configuration page.
There are not great examples of this anywhere (I have looked).

          "configurePage": {
            "url": "/my-config-page",
            "name": {
              "value": "my Configure Page"
            },
            "key": "my-config-page",

my button in the app manager is working nicely.
But the submission of data is proving tricky.

calling the request:

PUT /rest/atlassian-connect/1/addons/MODULE/properties/update-admin

works server side, fails client side.
So I’m trying to understand the preferred method to submit the data to store.

  • am I missing some trick with the auth from client side?
  • Is there a way to configure a PUT to the same config URL

How are you making the call on the client side. My first inclination after reading your post is that you’re not use the AP.request method which will handle making calls to the host project without needing to use CORS.

Docs: JavaScript API - Request

1 Like

Thanks for the reply. :slight_smile:

I attempted to use AP with limited success.
However a good rest payoff… I was able to store admin properties using:

AP.request({
  url: '/rest/atlassian-connect/1/addons/MODULE/properties/property-name',
  type: 'PUT',
  data: JSON.stringify({"data":"win"}),
  contentType:'application/JSON',
  success: function(responseText){
    alert(responseText);
  }
});

required request components to store admin app properties in confluence as JSON are:

  • when developing in the browser console use the “extension” context (not “top”)
  • contentType *required!
  • JSON data is required
  • The JSON data must be a string (eg. JSON.stringify)

Therequest documentation, only shows POST which may happily accept the raw JSON object. However PUT does not.
That was the gotcha for me.

best practice?

I see some other app using Iframes and Macros in their config pages.
I’m simply routing to a HTML (handlebars) simple page and will use client side JS to create the save/update interactions.

Is that wrong?
Is there a standard approach?