Creating content property using REST API receiving HTTP 500

Hi-- I’m using Atlassian Connect Express to build an add-on that needs to create custom content properties.

I’m using the following bit of code in my addon.js:

AP.request({
  url: '/rest/api/content/'+signaturesPageId.toString()+'/property',
  type: 'POST',
  contentType: 'application/json',
  data: {
	    "key": "signatures",
	    "value": {
	        "anything": "goes"
	    }
	},
  success: function(responseText){
    alert(responseText);
  },
  error: function(xhr, statusText, errorThrown){
    console.log(statusText);
  }
});

signaturesPageId is equivalent to {page.id}, it is passed in through the router.

This returns an HTTP 500. Tried with scopes (READ, WRITE) and (READ, WRITE, ADMIN).

Can anyone help?

I not really sure what is the correct one . But if you wrap your data with JSON.stringify it will work.

AP.request({
  url: '/rest/api/content/'+signaturesPageId.toString()+'/property',
  type: 'POST',
  contentType: 'application/json',
  data: JSON.stringify({
	    "key": "signatures",
	    "value": {
	        "anything": "goes"
	    }
	}),
  success: function(responseText){
    alert(responseText);
  },
  error: function(xhr, statusText, errorThrown){
    console.log(statusText);
  }
});
3 Likes