Create macro via REST API
Asked by Viktor Peacock:

Hi,

I am using REST API to dynamically create content. My goal is to:

- Create a page

- Create OPEN Swagger Macro within that page {open-api} JSON {open-api} with JSON content inside it

When posting this via the API, I end up with the following:

```
{open - api} {
 "swagger": "2.0",
 "info": {
 "version": "v1",
 "title": "My API"
 },
 "paths": {
 "/api/Values": {
 "get": {
 "tags": ["Values"],
 "operationId": "Get",
 "consumes": [],
 "produces": ["text/plain", "application/json", "text/json"],
 "parameters": [],
 "responses": {
 "200": {
 "description": "Success",
 "schema": {
 "uniqueItems": false,
 "type": "array",
 "items": {
 "type": "string"
 }
 }
 }
 }
 },
 "post": {
 "tags": ["Values"],
 "operationId": "Post",
 "consumes": ["application/json-patch+json", "application/json", "text/json", "application/*+json"],
 "produces": [],
 "parameters": [{
 "name": "value",
 "in": "body",
 "required": false,
 "schema": {
 "type": "string"
 }
 }],
 "responses": {
 "200": {
 "description": "Success"
 }
 }
 }
 },
 "/api/Values/{id}": {
 "get": {
 "tags": ["Values"],
 "operationId": "Get",
 "consumes": [],
 "produces": ["text/plain", "application/json", "text/json"],
 "parameters": [{
 "name": "id",
 "in": "path",
 "required": true,
 "type": "integer",
 "format": "int32"
 }],
 "responses": {
 "200": {
 "description": "Success",
 "schema": {
 "type": "string"
 }
 }
 }
 },
 "put": {
 "tags": ["Values"],
 "operationId": "Put",
 "consumes": ["application/json-patch+json", "application/json", "text/json", "application/*+json"],
 "produces": [],
 "parameters": [{
 "name": "id",
 "in": "path",
 "required": true,
 "type": "integer",
 "format": "int32"
 }, {
 "name": "value",
 "in": "body",
 "required": false,
 "schema": {
 "type": "string"
 }
 }],
 "responses": {
 "200": {
 "description": "Success"
 }
 }
 },
 "delete": {
 "tags": ["Values"],
 "operationId": "Delete",
 "consumes": [],
 "produces": [],
 "parameters": [{
 "name": "id",
 "in": "path",
 "required": true,
 "type": "integer",
 "format": "int32"
 }],
 "responses": {
 "200": {
 "description": "Success"
 }
 }
 }
 }
 },
 "definitions": {}
} {open - api}
```

Whilst JSON is there, the macro is not initialised. My question is how to correctly create and initialise macros via REST API.

The JSON represents a Swagger schema for a dummy API.

Thank you,

Viktor


Answers:
author: Linton Galloway
body: Hi Viktor

I'm looking to do the same thing with the open-api macro, have you made any progress?

Many thanks,

Linton


author: Stephen Sifers
body: Hello Viktor and welcome to the Community!

To understand more of what we're trying to achieve here, can you please clarify the following?

Are you attempting to create a macro within Confluence OR are you trying to develop a Confluence page with a macro within the content?

I look forward to your response so we can help to get an answer to this.

Regards,  
Stephen Sifers

comments: author: naveenkumar_dp
body: Hi Stephan,

I have also facing the same issue.

I wanted to create a confluence page along with the JIRA macro .

Can you please help us on this.

Thanks

Naveen


Tags: atl-adm

cloud

confluence-cloud