Skip to content

Move Site

Overview

Use the API to change the parent site (folder hierarchy) of a site.

Until now, sites could be moved only by drag and drop on the site menu. With this API, you can change the site hierarchy from an external program. The child sites of the site to be moved move together with it. You do not need to run the API for each child site.

Cautions

  1. Moving a site does not change its permission inheritance source (InheritPermission). To change the permission inheritance to match the destination, change it separately with Update Site or on the site settings screen.

Limitations

  1. You can specify only a folder (a site whose reference type is "Sites") as the destination. Specifying a table (Issues, Results, Wiki, and so on) as the destination results in an error.
  2. You cannot specify the site to be moved itself or any of its descendant sites as the destination. Doing so results in an error.
  3. You can specify only a site in the same tenant as the user who runs the API as the destination.
  4. ParentId of Update Site cannot be used to move a site. Use this API to move a site.

Prerequisites

  1. Create an API Key.
  2. The Enabled parameter of Api.json must be set to true.
  3. The user must have the "Manage site" permission for the site to be moved, the parent site of the site to be moved (the source), and the destination site. If the site to be moved is directly under the top, the permission for the source parent site is not required.

    Site hierarchy before and after the move. Folder X under Folder A is moved under Folder B. The "Manage site" permission is required for three sites: the source parent site (Folder A), the site to be moved (Folder X), and the destination site (Folder B). The child site moves together with Folder X

  4. If DisableTopSiteCreation of User.json is true, to specify the top (0 for ParentId) as the destination, the user must have "Allow creation at the top of the site" enabled in "User administration".

  5. If DisableMovingFromTopSite of User.json is true, to move a site directly under the top, the user must have "Allow moving from the top of the site" enabled in "User administration".

Request

Send JSON data in the following request format:

Setting item Value
HTTP Method POST
Content-Type application/json
Character Code UTF-8
URL http://{server name}/api/items/{site ID}/MoveSite1
Body Refer to the JSON data below

Items to Specify in Body

{
    "ApiVersion": 1.1,
    "ApiKey": "345yuAjA6789dA09d8uj6...",
    "ParentId": 12300
}

Specifying 0 for ParentId moves the site to the top.

{
    "ApiVersion": 1.1,
    "ApiKey": "345yuAjA6789dA09d8uj6...",
    "ParentId": 0
}

API Parameters

Item name Type Required Notes
ApiVersion Number Yes API version
ApiKey String Yes API key. Can be omitted when accessing from a browser session that is logged in
ParentId Number Yes Site ID of the destination parent site. Specifying 0 moves the site to the top

Execution Example Samples

To move a site under the folder with site ID "12300", specify the following.

Cautions

Modify {{ ... }} and the API key in the code as necessary.

PowerShell Sample

$body = @{
    ApiVersion = 1.1
    ApiKey     = "345yuAjA6789dA09d8uj6..."
    ParentId   = 12300
} | ConvertTo-Json
Invoke-RestMethod -Uri "https://{{server name}}/api/items/12345/MoveSite" -Method Post -ContentType "application/json; charset=utf-8" -Body $body

Python Sample

import requests

res = requests.post("https://{{server name}}/api/items/12345/MoveSite", json={
    "ApiVersion": 1.1,
    "ApiKey": "345yuAjA6789dA09d8uj6...",
    "ParentId": 12300,
})
print(res.status_code, res.json())

curl Sample

curl -X POST "https://{{server name}}/api/items/12345/MoveSite" \
  -H "Content-Type: application/json" \
  -d '{"ApiVersion":1.1,"ApiKey":"345yuAjA6789dA09d8uj6...","ParentId":12300}'

Response

If successful, JSON data in the following format is returned.

{
    "Id": 12345,
    "StatusCode": 200,
    "Message": "\" Sales Department \" has been moved."
}
Item name Type Notes
Id Number Site ID of the moved site
StatusCode Number HTTP status code
LimitPerDate Number Maximum number of API calls per day. Not output if no limit is set
LimitRemaining Number Remaining number of API calls for the day. Not output if no limit is set
Message String Message of the processing result

In case of an error, the following is returned.

StatusCode Message Situation
400 Invalid request. ParentId is not specified.
401 Unable to authorize.2 The API key is not specified or is invalid.
403 You do not have permission to perform this operation. The user does not have the "Manage site" permission for the site to be moved, the source parent site, or the destination site. Moving to the top or moving from the top is not allowed.
404 The specified information was not found. The site to be moved or the destination site does not exist. The destination is a site in another tenant.
500 This operation cannot be performed. The destination is not a folder. The site to be moved itself or one of its descendant sites is specified as the destination.

Confirmation Items in Case of Error

・Precautions when using the API and things to check if an error occurs
・FAQ: What to check if modified configuration files or API requests (JSON format) are not recognized correctly

Supported Versions

Supported versions Body
1.5.9.0 and later Added function

  1. Please edit the {server name} and {site ID} parts to suit your environment as appropriate. For {site ID}, specify the site ID of the site to be moved. For Pleasanter.net, the format is https://pleasanter.net/fs/api/items/{site ID}/MoveSite. ↩

  2. Because the user cannot be authenticated, the message is returned in the language set in DefaultLanguage of Service.json. When DefaultLanguage is ja, the message is returned in Japanese. ↩