Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column
Document Properties Marker
overridefalse
Short DescriptionLearn how to access projectdoc space properties via REST API with cURL.
 

Doctypetopichide
NameAccessing projectdoc Space Properties with cURL
 

Parent
Parent Property
propertyParent
property-nameName
 

Audience
Name List
doctyperole
render-no-hits-as-blanktrue
render-list-as-comma-separated-valuestrue
namesAuthor, Documentation Architect, Documentation Gardener
propertyAudience
empty-as-nonefalse
 

Level of Experience
Name List
doctypeexperience-level
render-no-hits-as-blanktrue
namesAdvanced Beginner
propertyLevel of Experience
empty-as-nonefalse
 

Expected Duration15 min
 

Subject
Name List
doctypesubject
propertySubject
 

Categories
Name List
doctypecategory
propertyCategories
 

Tags

Tag List
render-list-as-comma-separated-valuestrue
namesConfluence, curl, property, REST, Space
propertyTags

, REST

 

Iteration
Iteration
valuefilled
hide
Type
Name List
doctypetopic-type
render-no-hits-as-blanktrue
namesTip
propertyType
 

Sponsors
Name List
doctypestakeholder
render-no-hits-as-blanktrue
propertySponsors
 

Sort Keyhide
Column
width45%
Panel
titleContents

Table of Contents
maxLevel2
indent15px
stylenone

...

Section
titleExecuting REST Calls

After having installed the projectdoc Web API Extension to your Confluence instance choose a login method and start using the REST API. All the following examples use a cookie based login but feel free to take another choice.

This section will provide some examples how to get you started.

Let's assume you have already created a projectdoc workspace .

Section
titleQuery the Properties of a projectdoc Space

Query the newly created projectdoc space for its properties. To build such a query you need the space key of the space. Just choose "Overview" of the "Space tools" actions and retrieve it from the overview page.

Another option is to use the following JavaScript command in the console of your browser: AJS.params.spaceKey  

Note Box

This tip addresses all Web API Extension versions since 1.0. Starting with Version 1.1 it is mandatory to use the request parameter expand=property to retrieve properties. For older versions this property does not exist.

Now let us use this page ID in your first query:

Code Block Placeholder
code-themeMidnight
code-languageBash
code-titleQuery the properties of a projectdoc document
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home.json?expand=property | jq.

Here you can see the response:

Code Block Placeholder
code-themeSpaceDefault
code-languageBash
code-titleResponse
 {
  "id": 950274,
  "property": [
    {
      "source": "IDX",
      "name": "Categories",
      "value": ""
    },
    {
      "source": "IDX",
      "name": "documentation-json-uri",
      "value": "https://www.smartics.eu/confluence/download/attachments/12156954/docmap.json?api=v2"
    },
...

Besides JSON you can also get the response as XML. Just omit the extension or use .xml as extension:

Code Block Placeholder
code-themeMidnight
code-languageBash
code-titleQuery the properties of a projectdoc document (xml)
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home?expand=property | xmlstarlet  format --indent-tab
or
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home.xml?expand=property | xmlstarlet  format --indent-tab
Code Block Placeholder
code-themeSpaceDefault
code-languageBash
code-titleResponse (xml)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<space id="950274">
        <property>
                <source>IDX</source>
                <name>Categories</name>
                <value/>
        </property>
        <property>
                <source>IDX</source>
                <name>documentation-json-uri</name>
                <value>https://www.smartics.eu/confluence/download/attachments/12156954/docmap.json?api=v2</value>
        </property>
...
Section
titleReceiving Property Names, Values or both

If you would like to receive the values in a compact form use the following expression:

Code Block Placeholder
code-themeMidnight
code-languageBash
code-titleQuery the properties of a projectdoc document (pretty)
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home.json?expand=property | \
	jq   '[.property[] | { key : .name , value: .value}] | from_entries '
Code Block Placeholder
code-themeSpaceDefault
code-languageBash
code-titleResponse
{
  "Categories": "",
  "documentation-json-uri": "https://www.smartics.eu/confluence/download/attachments/12156954/docmap.json?api=v2",
  "DocumentPropertyRefs": "",
  "extract-short-description-from-metadata-table": "true",
  ...
}

Other possibilities are analogue to Accessing projectdoc Properties with cURL.

Section
titleReceive a single Property

Receiving only one property by accessing it explicitly (instead of filtering for it).

  • get the full property
  • get only the value
  • get the value without quotes
Code Block Placeholder
code-themeMidnight
code-languageBash
code-titleReceive a single property
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home/property/extract-short-description-from-metadata-table.json?expand=property | jq .
or
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home/property/extract-short-description-from-metadata-table.json?expand=property | jq .value
or
curl -s --cookie /tmp/confluence.cookie \
	https://www.example.com/confluence/rest/projectdoc/1/space/home/property/extract-short-description-from-metadata-table.json?expand=property | jq -r .value
Code Block Placeholder
code-themeSpaceDefault
code-languageBash
code-titleResponses
Full property:
 
{
  "source": "IDX",
  "name": "extract-short-description-from-metadata-table",
  "value": "true"
}

Only the value:
 
"true"
 
The value without quotes:
 
true

If the property (key) contains special characters which can not be part of an URL, they have to be escaped. For an example see how we solved this in the tip Accessing projectdoc Properties with cURL.

 
Section
titleResumé


Section
titleSubordinate Topics
Display Table
doctypetopic
render-no-hits-as-blanktrue
selectName, Short Description
restrict-to-immediate-childrentrue
sort-bySort Key, Name

...

Section
titleReferences
Section
titleResources

Piwik Set Multiple Custom Variables
NameValue
Departmentprojectdoc
Categoryprojectdoc-tip
Typehowto