Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Confluence API Get content template

Grzegorz Ostrowski
Contributor
January 25, 2022

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 Champion
January 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

Grzegorz Ostrowski
Contributor
January 25, 2022

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 Champion
January 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.

Grzegorz Ostrowski
Contributor
January 28, 2022

I am sorry for your trouble.

It was my simple mistake with powershell object.

But thanks for your reply

Pramodh M
Community Champion
January 28, 2022

Can you please accept the answer as accepted :-)

Jitesh Sevani
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 10, 2022

@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
Product Admin
TAGS
AUG Leaders

Atlassian Community Events