Chilkat Online Tools

Java / Atlassian Confluence Cloud / Remove template

Back to Collection Items

import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttp http = new CkHttp();
    boolean success;

    // Adds the "Authorization: Bearer <access_token>" header.
    http.put_AuthToken("<access_token>");

    CkHttpResponse resp = http.QuickRequest("DELETE","https://your-domain.atlassian.net/wiki/rest/api/template/:contentTemplateId");
    if (http.get_LastMethodSuccess() == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    int respStatusCode = resp.get_StatusCode();
    System.out.println("Response Status Code = " + respStatusCode);
    if (respStatusCode != 204) {
        System.out.println("Response Header:");
        System.out.println(resp.header());
        System.out.println("Response Body:");
        System.out.println(resp.bodyStr());
        System.out.println("Failed.");

        return;
        }

    System.out.println("Success.");
  }
}

Curl Command

curl -X DELETE
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/template/:contentTemplateId

Postman Collection Item JSON

{
  "name": "Remove template",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "DELETE",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/template/:contentTemplateId",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "template",
        ":contentTemplateId"
      ],
      "variable": [
        {
          "key": "contentTemplateId",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The ID of the template to be deleted."
        }
      ]
    },
    "description": "Deletes a template. This results in different actions depending on the\ntype of template:\n\n- If the template is a content template, it is deleted.\n- If the template is a modified space-level blueprint template, it reverts\nto the template inherited from the global-level blueprint template.\n- If the template is a modified global-level blueprint template, it reverts\nto the default global-level blueprint template.\n\n Note, unmodified blueprint templates cannot be deleted."
  },
  "response": [
    {
      "name": "Returned if the template has been successfully been deleted.",
      "originalRequest": {
        "method": "DELETE",
        "header": [
          {
            "description": {
              "content": "Added as a part of security scheme: oauth2",
              "type": "text/plain"
            },
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "url": {
          "raw": "{{baseUrl}}/api/template/:contentTemplateId",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "template",
            ":contentTemplateId"
          ],
          "variable": [
            {
              "key": "contentTemplateId"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}