problem with response from rest/api/content/history/macro/id

319 views
Skip to first unread message

Юрий Клещенок

unread,
Jul 15, 2015, 11:27:21 AM7/15/15
to atlassian-...@googlegroups.com
I'm trying place JiraMacro (or any other) into my macro, but when i call rest api, get only '<p><p>'.

Storage:
<p><ac:structured-macro ac:name="jira" ac:schema-version="1" ac:macro-id="1393fd5d-3e32-4792-a5ec-49c6f573ffea"><ac:parameter ac:name="server">Atlassian JIRA</ac:parameter><ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter><ac:parameter ac:name="maximumIssues">10</ac:parameter><ac:parameter ac:name="jqlQuery">project = 13310 AND fixVersion = 50817 ORDER BY priority DESC, key ASC </ac:parameter><ac:parameter ac:name="serverId">144880e9-a353-312f-9412-ed028e8166fa</ac:parameter></ac:structured-macro></p><p>asdf</p><ac:structured-macro ac:name="code" ac:schema-version="1" ac:macro-id="ef63a699-3ddf-4bb9-95d8-6ad31e58bcd8"><ac:parameter ac:name="language">cpp</ac:parameter><ac:plain-text-body><![CDATA[sdfg
int lalka;]]></ac:plain-text-body></ac:structured-macro><p>&nbsp;</p> 

atlassian-connect.json:
"url": "/macro-page?pageId={page.id}&pageVersion={page.version}&macroId={macro.id}",            

my.js(view mode):
AP.require("request", function(request) {
        request({
            url: "/rest/api/content/" + "{{pageId}}"
                    + "/history/" + "{{pageVersion}}"
                    + "/macro/id/" + "{{macroId}}",
            success: function(response){
                console.log(JSON.parse(response).body); // empty '<p><p>' body
            }
        })
});

But, in editor mode all is fine.
confluence.getMacroBody(function(body) {
        console.log(body); //body with macro

How i can get this storage from rest?

Peter Brownlow

unread,
Jul 16, 2015, 3:08:51 AM7/16/15
to atlassian-...@googlegroups.com, kleshch...@gmail.com
Hi,

Can you confirm that you can get the macro details you expect when you browse to the REST API?
(i.e. when you simply go to the URL in your browser)

-Peter

Юрий Клещенок

unread,
Jul 16, 2015, 11:49:52 AM7/16/15
to atlassian-...@googlegroups.com, kleshch...@gmail.com
In browser:
{"name":"my-macro","body":"<p></p>","_links":{"base":"http://my-PC:1990/confluence","context":"/confluence"}}

I add "asdf" inside with jira macro and get this:
{"name":"my-macro","body":"<p></p><p>asdf</p>","_links":{"base":"http://my-PC:1990/confluence","context":"/confluence"}}

четверг, 16 июля 2015 г., 10:08:51 UTC+3 пользователь Peter Brownlow написал:

Peter Brownlow

unread,
Jul 16, 2015, 7:22:15 PM7/16/15
to atlassian-...@googlegroups.com, kleshch...@gmail.com
Because the responses from using the JS API and simply typing the URL into your browser match it appears that Connect's JS API is functioning correctly and that therefore this is really a question about Confluence's behaviour.

The storage format that you posted in your first message contains a trailing "<p>&nbsp;</p>". Is this the data that you are storing? Can you try getting rid of this suffix to see what effect this has?

Юрий Клещенок

unread,
Jul 17, 2015, 5:27:03 AM7/17/15
to atlassian-...@googlegroups.com, kleshch...@gmail.com
Without "<p>&nbsp;</p>" problem still here.

Peter Brownlow

unread,
Jul 20, 2015, 7:01:46 PM7/20/15
to atlassian-...@googlegroups.com, kleshch...@gmail.com
Here's another thought: there's a leading "<p>". Can you try getting rid of this prefix?

Matthew Jensen

unread,
Jul 21, 2015, 12:07:41 AM7/21/15
to atlassian-...@googlegroups.com
Hello Юрий,

I have written some python code to verify if the rest api is working as expected, which it did.  I have some comments.

* In your example, its not clear where you are getting the pageId, pageVersion and macroId, can you show us that by attaching the entire file to this thread please.
* A few things to note about the macro Id's.  If you are specifying one (like you are in the example) and you are adding to a page that already contains that macro Id, then one of the id's will be regenerated (to make sure its unique).   Is the page you are working with empty apart from the storage format you are creating?  Unless you can be pretty sure no one else is going to use the macro id, you are better off not specifying it when creating the page content.
* The configuration for the macro you are setting the body for (my-macro) must have a body type set, can you please also attach the definition of this macro from your addon descriptor?

If you like, and it may make it easier to share some of these files I have asked for, you can create a support request in the 'Confluence Ecosystem' project here: https://ecosystem.atlassian.net/secure/CreateIssue!default.jspa

Cheers
Matt

--
You received this message because you are subscribed to the Google Groups "Atlassian Connect Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to atlassian-connec...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Yuri Kleshchenok

unread,
Jul 27, 2015, 7:02:35 PM7/27/15
to Atlassian Connect Dev, mje...@atlassian.com
Here's another thought: there's a leading "<p>". Can you try getting rid of this prefix?
Without leading "<p>" response: "";

 In your example, its not clear where you are getting the pageId, pageVersion and macroId, can you show us that by attaching the entire file to this thread please.
Index.js:
app.get('/macro-page', addon.authenticate(), function(req, res) {
    var column = req.param('column');        
    var pageId = req.param('pageId');
    var pageVersion = req.param('pageVersion');
    var macroId = req.param('macroId');        

    res.render('macro/macro-view', {            
           pageId: pageId,
      pageVersion: pageVersion,
      macroId: macroId            
       });   
});

 A few things to note about the macro Id's.  If you are specifying one (like you are in the example) and you are adding to a page that already contains that macro Id, then one of the id's will be regenerated (to make sure its unique).   Is the page you are working with empty apart from the storage format you are creating?  Unless you can be pretty sure no one else is going to use the macro id, you are better off not specifying it when creating the page content.

I create new empty page and place on it only my macro and jira macro inside, both macro has unique id. Response: "<p></p>". 
Full storage of page: 
<ac:structured-macro ac:macro-id="e1f14bb3-385f-48cf-ab2e-ad9ab9c0b2e6" ac:name="table-filter" ac:schema-version="1"><ac:rich-text-body>
<p><ac:structured-macro ac:macro-id="75754a40-e72f-45dd-8b45-720c1c7dcb3d" ac:name="jira" ac:schema-version="1"><ac:parameter ac:name="server">Atlassian JIRA</ac:parameter><ac:parameter ac:name="columns">key,summary,type,created,updated,due,assignee,reporter,priority,status,resolution</ac:parameter><ac:parameter ac:name="maximumIssues">20</ac:parameter><ac:parameter ac:name="jqlQuery">project = 13310 AND fixVersion = 50817 ORDER BY priority DESC, key ASC </ac:parameter><ac:parameter ac:name="serverId">144880e9-a353-312f-9412-ed028e8166fa</ac:parameter></ac:structured-macro></p></ac:rich-text-body></ac:structured-macro>

The configuration for the macro you are setting the body for (my-macro) must have a body type set, can you please also attach the definition of this macro from your addon descriptor?
atlassian-connect.json:
"bodyType": "RICH-TEXT"

 


Yuri Kleshchenok

unread,
Jul 27, 2015, 7:02:36 PM7/27/15
to Atlassian Connect Dev, mje...@atlassian.com
I try get body of macro(by rest url in browser) that i place on a page(not inside my macro), and get "". So, looks like, 'rest/api/content/pageId/hidtory/pageVersion/macro/id/macroId' dont work at all for me.

Yuri Kleshchenok

unread,
Jul 29, 2015, 2:56:39 AM7/29/15
to Atlassian Connect Dev, mje...@atlassian.com, yklesh...@stiltsoft.com
additional info:

atlas-version:
ATLAS Version:    5.0.13
ATLAS Home:       d:\work\programms\atlassian-plugin-sdk
ATLAS Scripts:    d:\work\programms\atlassian-plugin-sdk\bin
ATLAS Maven Home: d:\work\programms\atlassian-plugin-sdk\apache-maven-3.2.1
--------
Executing: "d:\work\programms\atlassian-plugin-sdk\apache-maven-3.2.1\bin\mvn.bat" --versi
on -gs d:\work\programms\atlassian-plugin-sdk\apache-maven-3.2.1/conf/settings.xml
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256M; support was r
emoved in 8.0
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T20:37:52+03:00)
Maven home: d:\work\programms\atlassian-plugin-sdk\apache-maven-3.2.1\bin\..
Java version: 1.8.0_51, vendor: Oracle Corporation
Java home: c:\Program Files\Java\jdk1.8.0_51\jre
Default locale: ru_RU, platform encoding: Cp1251
OS name: "windows 7", version: "6.1", arch: "amd64", family: "dos"
run-command:
atlas-run-standalone --product confluence --version 5.9.1-OD-61-011 --bundled-plugins com.atlassian.bundles:json-schema-validator-atlassian-bundle:1.0.4,com.atlassian.webhooks:atlassian-webhooks-plugin:1.0.6,com.atlassian.jwt:jwt-plugin:1.2.2,com.atlassian.upm:atlassian-universal-plugin-manager-plugin:2.19.0.6-D20150709T232251,com.atlassian.plugins:atlassian-connect-plugin:1.1.38 --jvmargs -Datlassian.upm.on.demand=true

Reply all
Reply to author
Forward
0 new messages