How to Change URLs of External Gadgets

Still need help?

The Atlassian Community is here for you.

Ask the community

Symptoms

When you create External Gadgets in Confluence, there is no option to edit the existing gadget's URL, if needed. This might be extremely painful if you're using it across many pages.

For example:

http://test.com:8080/rest/gadgets/1.0/g/com.atlassian.jira.gadgets:pie-chart-gadget/gadgets/piechart-gadget.xml

And I need to change it to:

http://newtest.com/jira/rest/gadgets/1.0/g/com.atlassian.jira.gadgets:pie-chart-gadget/gadgets/piechart-gadget.xml

Workaround

Create a database backup before changing anything!

Additionally, any database modifications should be done while Confluence is shut down and not running.


Since changing the gadget's URL is not possible via Confluence interface, you will need to modify the URLs in the database.

  1.  Stop Confluence following your standard procedure.

  2. If Collaborative Editing is enabled, run the following SQL query to force Synchrony to retrieve draft content from the database.

    You may need to adjust the SQL statement to work with your specific database engine.

    update CONTENTPROPERTIES set STRINGVAL = 'synchrony-recovery' where PROPERTYID in (
        select cp.PROPERTYID
        from BODYCONTENT bc
        join CONTENTPROPERTIES cp on cp.CONTENTID=bc.CONTENTID
        where bc.BODY like '%http://test.com:8080%'
        and cp.PROPERTYNAME = 'sync-rev-source'
    )
    ;
  3. Run a SQL statement to update the body content. An example is shown below: 

    tip/resting Created with Sketch.

    You may need to adjust the SQL statement to work with your specific database engine.

    update BODYCONTENT
    set body = replace(body, 'http://test.com:8080', 'http://newtest.com/jira')
    where body like '%http://test.com:8080%';
    UPDATE BODYCONTENT
    SET BODY=REPLACE(cast(BODY as nvarchar(max)),'http://test.com:8080','http://newtest.com/jira')
    where BODY like '%http://test.com:8080%';
    update BODYCONTENT
    set body = replace(body, 'http://test.com:8080', 'http://newtest.com/jira')
    where body like '%http://test.com:8080%'; 
  4. Start Confluence following your standard procedure.
  5. After all the occurrences of gadgets are updated by the SQL above,  add the new base URL to the "External Gadgets" section in Confluence Admin.
  6. In case the application does not recognize the new links for the gadgets (pointing to previous URL still), go ahead and re-index your instance since these URLs may be cached somewhere.
     
Last modified on Mar 21, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.