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.  Shutdown Confluence  

  2. 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 type.

    update BODYCONTENT set body = replace(body, 'test.com:8080', 'newtest.com/jira') where body like '%test.com:8080%';
    
    -- For Microsoft SQLServer use the following query:
    UPDATE BODYCONTENT SET body=REPLACE(cast(body as nvarchar(max)),'test.com:8080','newtest.com/jira') where body like '%test.com:8080%';
  3. Restart Confluence.
  4. 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.
  5. In case the application does not recognise 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 Nov 12, 2018

Was this helpful?

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