Should passing the URL parameters for createblogpost.action work with Confluence 4.0 as well?
Asked by Juha Meronen:

I have been using this kind of URL links with previous versions of Confluence:  

|--------------------------------------------------------------------------|
| `.../wiki/pages/createblogpost.action?spaceKey=space&labelsString=label` |

It seems that the labels parameters are not passed on for the blog post at all anymore.

Is there any way to get this working with Confluence 4.0?


Answers:
author: Remo Siegwart
body: This should still work in Confluence 4.0 with the parameter **labelsString**, it works at least in our environment. They won't be displayed in the label editor, but they will be added to the page/blogpost after saving.

I'm not sure whether this is a bug or a feature. You can pass multiple labels with **labelsString=test1,test2** and then even add a third label (for example: **label3**) in the editor. Confluence will add all three labels to the page/blogpost. I can think of some use cases where hiding those passed labels would make sense.

Hope this helps

comments: author: Juha Meronen
body: Remo, thanks a lot! This resolves my issue completely. It is actually even BETTER that the label parameters passed over in URL are not shown in label editor (the user cannot remove them...).


author: Remo Siegwart
body: Exactly, that's the use case I was thinking about. I'm glad that this resolves your issue!


author: KPAH
body: `&labelsString=label doesn't work in 4.3`

or should I still insert the script code for it to work?


author: Remo Siegwart
body: It still works, without any script code. Just use the following url:

[http://path.to.your.confluence/pages/createblogpost.action?spaceKey=TEST\&labelsString=label1,label2](http://path.to.your.confluence/pages/createblogpost.action?spaceKey=TEST&labelsString=label1,label2)

Note that the labels are not displayed in the editor during the creation of the blogpost. But they will be visible after saving.


author: KPAH
body: I actually tested that for several minutes before posting my initial reply.

I didn't insert the code through the admin panel.

I use the abovementiond url with corrections to my server url and spacekey, it doesn't show the labels in the labels and it doesn't show them after I publish the post either...

I also tried the user macro to do that that is in the user macro repository or something here on Atlassian website, it also doesn't add the labels.


author: Remo Siegwart
body: Strange, I just successfully tested it in three different Confluence instances with different users and different permissions. Can you confirm that you are able to add a label to a blogpost over the default UI?


author: KPAH
body: Yes, sure I can add labels. I even use links on my webpages that create _pages_ in a specified space and with a specified template, that works fine, confirming it's not a browser issue (stripping redirects or whatever).

I'm using a standalone Confluence 4.3. The only code I added to the Custom HTML is the javascript to swicth off Notify watchers.

Are there any other parameters I could test with the createblopost.action to make sure they pass or not?

Thanks.


author: Remo Siegwart
body: There are other parameters like spaceKey, but I'm sure they'll work. Sorry, don't really know what to do here, maybe check the log for any errors or contact Atlassian support.


author: KPAH
body: Remo, sorry I was incorrect.

Indeed it works and passes labels on blog creation. Don't know why it didn't work for me yesterday evening, but it does today's morning.:) I'm planning to add some convenient buttons with those links.

Thanks.


author: Sandro Herrmann [Communardo]
body: Yes you can do this with a little bit of javascript. Insert the following code to your Administration \> Custom HTML \> "At the end of the BODY"-part

```
&lt;script type="text/javascript"&gt; AJS.toInit(function ($) {       //is it a create page action which is called??     if( window.location.href.indexOf("createpage.action") &gt; -1 || window.location.href.indexOf("createblogpost.action")) {                 //if yes is there a label given as request parameter???        var label = getUrlVars()["labelsString"];        if(label) {                         //simply click the labeleditbutton            jQuery("#rte-button-labels").trigger("click");            //insert the label parameter value            jQuery("#labelsString").val(label);            //and close the label editor            jQuery("#add-labels-editor-button").trigger("click");            jQuery(".dialog-button-panel a.button-panel-cancel-link").trigger("click");        }    }}); //this function is needed to get the parameters from the urlfunction getUrlVars(){    var vars = [], hash;    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&amp;');    for(var i = 0; i &lt; hashes.length; i++)    {        hash = hashes[i].split('=');        vars.push(hash[0]);        vars[hash[0]] = hash[1];    }    return vars;} &lt;/script&gt;&lt;br&gt;&lt;br&gt;
```

Now you can use your "labelsString" Parameter. Don't forget to clear your browser cache with Ctrl+R. Testet with my Confluence 4.0.

comments: author: eyrisone
body: It looks like the URL method is broken again (Confluence 5.9.3).

Sandro, your solution works perfectly for me (thank you!), but the labels window remains open after clicking the link.

I tried changing ".dialog-button-panel a.button-panel-cancel-link" to a couple of different things, but nothing I tried worked.

Any ideas?


author: Ingrid Schipper
body: We experience the same problems with the url method in5.9.4. Anyone any ideas how to solve it.


author: Auke_Miedema
body: see <https://jira.atlassian.com/browse/CONF-37848>

A solutiion that fixes the url method is installing the recently published free Bitvoodoo add-on Label Fixer