Rest API for Content Property list is empty

Hi,

I have a P2 Macro and I need to make data from the macro parameters available in javascript. According to all the (mildly contradicting and confusing) documentation, I should be able to set Content Properties on the page using the JAVA API, and then use REST API to retrieve the data.

For me, this does not work…

On the JAVA side I am creating the Content property using this call inside my Macro function execute():

ContentProperties cp = conversionContext.getEntity().getProperties();
cp.setStringProperty("test", "this is a test")

The on the JS side, I use the REST API to read the content properties using this ajax call:

AJS.$.ajax({ 
  type: "get",
  url: AJS.params.baseUrl + "/rest/api/content/" + AJS.params.pageId + "/property",
  success: function(data)
  { console.log(data);}
});

However the result returned is empty, what am I doing wrong. This is so frustrating, I’ve been trolling through so much literature and nothing works for me?

Please help