How to store data entered in the HTML Macro

Stefan Mueller April 17, 2019

Hello,
I create a simple HTML, JS code, embedded via the HTML Macro.
The user is supposed to enter some data, what works like charm.

How can I store this data server-side to ensure that is available the next time, the user opens this space.

thank you

Stefan

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 22, 2019

Hello Stefan,

Your question is a great question and it points to how versatile Confluence is capable of being. Within the HTML macro itself, you will need to use PHP within there to make API calls to endpoints to ingest the inserted data. There are multiple guides that will walk you through on how to use PHP and a REST API together. A great and detailed guide may be found at How To Create A Simple REST API in PHP? Step By Step Guide!

Along with this, there is a guide on how to use PHP within Confluence using the HTML macro. That guide may be found at How to use PHP inside Confluence pages.

I hope this proves helpful and you’re able to start ingesting some of your user content via the REST API.

Regards,
Stephen Sifers

Stefan Mueller April 22, 2019

Hoi Stephen,

thanks for pointing me in the PHP direction but that requires not little work(around) to get it done. Isn't there any possibility to make use of Confluence's APIs?

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 22, 2019

Hello Stefan,

HTML by itself does not directly work with REST API POST/PUT calls due to the requirements of authentication. With this said, you will need to use something such as PHP to allow for triggers which then authenticate and make the authenticated REST API calls to Confluence (Or any other service you want to update).

Another alternative would be to use Javascript, but the entry point for PHP is simpler than Javascript. Mainly due to simplified working examples of how to make REST API calls with PHP readily available.

Regards,
Stephen Sifers

Stefan Mueller April 22, 2019

I agree that PHP could be simpler in the long term but JS can be inlcuded easily, PHP needs an extra server.

Roberta Bortolotti June 14, 2022

Hi,

This is good information, but do we need to have PHP installed in the Confluence Server? It seems that with JS we might not need to install anything extra in the server itself. Please let me know if I am incorrect here.

Thank you,

Roberta

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events