Chilkat Online Tools

C# / Atlassian Confluence Cloud / Delete relationship

Back to Collection Items

// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

Chilkat.Http http = new Chilkat.Http();
bool success;

// Adds the "Authorization: Bearer <access_token>" header.
http.AuthToken = "<access_token>";

Chilkat.HttpResponse resp = http.QuickRequest("DELETE","https://your-domain.atlassian.net/wiki/rest/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>");
if (http.LastMethodSuccess == false) {
    Debug.WriteLine(http.LastErrorText);
    return;
}

int respStatusCode = resp.StatusCode;
Debug.WriteLine("Response Status Code = " + Convert.ToString(respStatusCode));
if (respStatusCode != 204) {
    Debug.WriteLine("Response Header:");
    Debug.WriteLine(resp.Header);
    Debug.WriteLine("Response Body:");
    Debug.WriteLine(resp.BodyStr);
    Debug.WriteLine("Failed.");

    return;
}

Debug.WriteLine("Success.");

Curl Command

curl -X DELETE
	-H "Authorization: Bearer <access_token>"
https://your-domain.atlassian.net/wiki/rest/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>

Postman Collection Item JSON

{
  "name": "Delete relationship",
  "request": {
    "auth": {
      "type": "oauth2"
    },
    "method": "DELETE",
    "header": [
    ],
    "url": {
      "raw": "{{baseUrl}}/api/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "api",
        "relation",
        ":relationName",
        "from",
        ":sourceType",
        ":sourceKey",
        "to",
        ":targetType",
        ":targetKey"
      ],
      "query": [
        {
          "key": "sourceStatus",
          "value": "<string>",
          "description": "The status of the source. This parameter is only used when the\n`sourceType` is 'content'."
        },
        {
          "key": "targetStatus",
          "value": "<string>",
          "description": "The status of the target. This parameter is only used when the\n`targetType` is 'content'."
        },
        {
          "key": "sourceVersion",
          "value": "<integer>",
          "description": "The version of the source. This parameter is only used when the\n`sourceType` is 'content' and the `sourceStatus` is 'historical'."
        },
        {
          "key": "targetVersion",
          "value": "<integer>",
          "description": "The version of the target. This parameter is only used when the\n`targetType` is 'content' and the `targetStatus` is 'historical'."
        }
      ],
      "variable": [
        {
          "key": "relationName",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The name of the relationship."
        },
        {
          "key": "sourceType",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The source entity type of the relationship. This must be 'user', if\nthe `relationName` is 'favourite'."
        },
        {
          "key": "sourceKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) - The identifier for the source entity:\n\n- If `sourceType` is 'user', then specify either 'current' (logged-in\n  user) or the user key.\n- If `sourceType` is 'content', then specify the content ID.\n- If `sourceType` is 'space', then specify the space key."
        },
        {
          "key": "targetType",
          "value": "<string>",
          "type": "string",
          "description": "(Required) The target entity type of the relationship. This must be 'space' or\n'content', if the `relationName` is 'favourite'."
        },
        {
          "key": "targetKey",
          "value": "<string>",
          "type": "string",
          "description": "(Required) - The identifier for the target entity:\n\n- If `sourceType` is 'user', then specify either 'current' (logged-in\n  user) or the user key.\n- If `sourceType` is 'content', then specify the content ID.\n- If `sourceType` is 'space', then specify the space key."
        }
      ]
    },
    "description": "Deletes a relationship between two entities (user, space, content).\n\n**[Permissions](https://confluence.atlassian.com/x/_AozKw) required**:\nPermission to access the Confluence site ('Can use' global permission).\nFor favourite relationships, the current user can only delete their own\nfavourite relationships. A space administrator can delete favourite\nrelationships for any user."
  },
  "response": [
    {
      "name": "Returned if the relationship is deleted or the relationship didn't\nexist.",
      "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/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "No Content",
      "code": 204,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the user does not have permission to delete the\nrelationship.",
      "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/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "Forbidden",
      "code": 403,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "Returned if the user, space or content could not be found.",
      "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/relation/:relationName/from/:sourceType/:sourceKey/to/:targetType/:targetKey?sourceStatus=<string>&targetStatus=<string>&sourceVersion=<integer>&targetVersion=<integer>",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "api",
            "relation",
            ":relationName",
            "from",
            ":sourceType",
            ":sourceKey",
            "to",
            ":targetType",
            ":targetKey"
          ],
          "query": [
            {
              "key": "sourceStatus",
              "value": "<string>"
            },
            {
              "key": "targetStatus",
              "value": "<string>"
            },
            {
              "key": "sourceVersion",
              "value": "<integer>"
            },
            {
              "key": "targetVersion",
              "value": "<integer>"
            }
          ],
          "variable": [
            {
              "key": "relationName"
            },
            {
              "key": "sourceType"
            },
            {
              "key": "sourceKey"
            },
            {
              "key": "targetType"
            },
            {
              "key": "targetKey"
            }
          ]
        }
      },
      "status": "Not Found",
      "code": 404,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}