Hello,
I'm trying to get data from external API(non-Atlassian software) using user-macro feature. All the examples that I see and working are all getting API data from either Confluence or Jira. I'm wondering if user-macro feature with ajax doesn't work with external API.
Disclaimer: I'm new to Confluence.
Here is a sample:
## @param Name:title=Name|type=string|required=true|desc=Your name <script type="javascript> AJS.$.ajax({ url: URL_WITH_NO_QUOTES, type: "GET", contentType: "application/json", success: function(msg){ alert(msg); } }); </script>
Thanks!
Hi Dong!
It looks like an answer in the community link you posted might have the answer you're looking for:
I suppose $ is treated as a special character used by Velocity template. So, you need to escape it.I hope the following code will work.
## @param Name:title=Name|type=string|required=true|desc=Your name #set($D='$') <script type="text/javascript"> AJS.${D}.ajax({ url: URL_WITH_NO_QUOTES, type: "GET", contentType: "application/json", success: function(msg){ alert(msg); } }); </script>
Besides, <script type="javascript>
in your code should be quoted properly.
If the updated script above doesn't work, can you describe what happens when you try to use it? It will also help to know if you see any new network calls when you load the macro.
To do this:
I hope this helps!
– Zak
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.