Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,306
Community Members
 
Community Events
176
Community Groups

Confluence API Get content template

I am trying to create page from template using powershell in yaml pipeline.

This is my code:

$urlGetTemplate = "https://???.atlassian.net/wiki/rest/api/template/33980675"
      Write-Host "URL: $urlGetTemplate"
      $username = "?????????"
      $password = "?????????"
      $base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $username,$password)))
      $headers = @{
          'Authorization' = 'Basic ' + $base64AuthInfo
          'X-Atlassian-Token' = 'no-check'
          'Connection' = 'keep-alive'
      }
      Write-Host "base64AuthInfo:" $base64AuthInfo
      [string]$templateObject = Invoke-RestMethod -Method Get -Uri $urlGetTemplate -ContentType "application/json" -Headers $headers
        
I dont get any error, but I get this empty template: 
{
templateId=33980675;
originalTemplate=;
referencingBlueprint=com.atlassian.confluence.plugins.confluence-business-blueprints:file-list-blueprint@DOK;
name=File list;
description=Upload, preview and share files with your team.;
space=;
labels=System.Object[];
templateType=page;
editorVersion=v2;
body=;
_links=
}
I checked the same Request using postman and SoapUI and I get json with full template data. Can anybody tell me why Powershell Invoke-RestMethod gives me empty json without error?

1 answer

1 accepted

0 votes
Answer accepted
Pramodh M Community Leader Jan 25, 2022

Yeah @Grzegorz Ostrowski 

I'm afraid this is not yet supported for Cloud

Here's the reference for the feature request

https://jira.atlassian.com/browse/CONFCLOUD-11393

Let me know if you have any queries

Thanks,
Pramodh

Thanks for reply.

 

So it is not possible to get project template using powershell?

I dont wont to create page from template in one API method. I want only to get project template using API method GET /wiki/rest/api/template/{contentTemplateId} 

I am able to get full json template using SopaUI or postman, why powershell returns me nearly empty json with 200 response. I use powershell in jira and confluence API to add Attachments and Pages with success, but why I cant get template through API?

Pramodh M Community Leader Jan 25, 2022

Hi @Grzegorz Ostrowski 

Try this API

https://developer.atlassian.com/cloud/confluence/rest/api-group-template/#api-wiki-rest-api-template-blueprint-get

GET /wiki/rest/api/template/blueprint

With the above API you should be able to get all the templates


GET /wiki/rest/api/template/{contentTemplateId}  - this one is for templates which you have built.

I am sorry for your trouble.

It was my simple mistake with powershell object.

But thanks for your reply

Pramodh M Community Leader Jan 28, 2022

Can you please accept the answer as accepted :-)

@Grzegorz Ostrowski  What was the mistake you made? Can you clarify?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS

Atlassian Community Events