Documentation deprecated: This documentation is no longer being updated as of 3.8.0. For up-to-date information, see the guide information in the IBM Developer Community and the endpoint reference in IBM API Explorer.

/files/rename

Rename the specified files and directories. Existing files and directories cannot be overwritten by a /files/rename request. To rename files by using bearer token authentication, use the /files endpoint.

Requirements
  • Available as of Enterprise Server version 3.0.0.
Access Control
  • HTTP Basic Auth
    Users who authenticate with Node API credentials can rename items in paths that are within their docroot. Access key users can rename items in paths that are within the path set in the access key.
URL
POST https://{domain}:9092/files/rename

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/rename \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [
        { 
            "path" : "/full/path/to/parent/dir", 
            "source" : "old_dir_name", 
            "destination" : "new_dir_name" 
        },
        { 
            "path" : "/full/path/to/parent/dir", 
            "source" : "old_file_name", 
            "destination" : "new_file_name" 
        }
    ]
}

Headers
Header Name Required Description Values
Content-Type Optional The format of the request data. application/json
Accept Optional The format of the response data. application/json
Request Body
Element Required Type Description
paths Required JSON A JSON array of the files, symlinks, and directories to rename.
path Required String The full path to the parent directory of the file, symbolic link, or directory to rename.
source Required String The current name of the file, symbolic link, or directory.
destination Required String The new name for the file, symbolic link, or directory.
Sample Response
HTTP/1.1 200 OK
Cache: no-cache
Connection: close
Content-Type: application/json; charset=utf-8

{
    "paths" : [
        {
            "path" : "/Users/aspera/Documents",
            "source" : "test_folder_old",
            "destination" : "test_folder_new"
        },
        {
            "path" : "/Users/aspera/Documents/",
            "source" : "file_old.txt",
            "destination" : "file_new.txt",
        },
        {
            "path" : "/Users/aspera/Documents/",
            "source" : "test_folder",
            "destination" : "test_folder_new",
            "error" : { 
                "code" : 404, 
                "reason" : "Not Found", 
                "user_message" : "No such file or directory" 
            }
        }
    ]
}

Status Codes and Errors
Code Description Notes
200 OK Success
400 Bad Request Error Request contains a formatting or syntax error.
404 Not Found Error Invalid pathname.
409 Conflict Error New pathname already exists.
500 Internal Server Error Error The server configuration is invalid.
Response
The response body contains the same information as the request body unless the rename fails, in which case error information is returned.
Element Type Description
error String If file or directory rename fails, a JSON array that contains details about the error.
code Unsigned integer Error code.
reason String Short description of error.
user_message String Longer description of error.

/files/rename

Rename the specified files and directories. Existing files and directories cannot be overwritten by a /files/rename request.

Requirements
  • Available as of Enterprise Server version 3.0.0.
Access Control
  • HTTP Basic Auth
    Users who authenticate with Node API credentials can rename items in paths that are within their docroot. Access key users can rename items in paths that are within the path set in the access key.

To rename files by using bearer token authentication, use the /files endpoint.

URL
POST https://{domain}:9092/files/rename

Sample Request
curl -i -u user:secret -X POST https://{domain}:9092/files/rename \
     -H "Content-Type: application/json" \
     -H "Accept: application/json" \
     -d @request_body.json

Where request_body.json contains the following:
{
    "paths" : [
        { 
            "path" : "/full/path/to/parent/dir", 
            "source" : "old_dir_name", 
            "destination" : "new_dir_name" 
        },
        { 
            "path" : "/full/path/to/parent/dir", 
            "source" : "old_file_name", 
            "destination" : "new_file_name" 
        }
    ]
}

Headers
Header Name Required Description Values
Content-Type Optional The format of the request data. application/json
Accept Optional The format of the response data. application/json
Request Body
Element Required Type Description
paths Required JSON A JSON array of the files, symlinks, and directories to rename.
path Required String The full path to the parent directory of the file, symbolic link, or directory to rename.
source Required String The current name of the file, symbolic link, or directory.
destination Required String The new name for the file, symbolic link, or directory.
Sample Response
HTTP/1.1 200 OK
Cache: no-cache
Connection: close
Content-Type: application/json; charset=utf-8

{
    "paths" : [
        {
            "path" : "/Users/aspera/Documents",
            "source" : "test_folder_old",
            "destination" : "test_folder_new"
        },
        {
            "path" : "/Users/aspera/Documents/",
            "source" : "file_old.txt",
            "destination" : "file_new.txt",
        },
        {
            "path" : "/Users/aspera/Documents/",
            "source" : "test_folder",
            "destination" : "test_folder_new",
            "error" : { 
                "code" : 404, 
                "reason" : "Not Found", 
                "user_message" : "No such file or directory" 
            }
        }
    ]
}

Status Codes and Errors
Code Description Notes
200 OK Success
400 Bad Request Error Request contains a formatting or syntax error.
404 Not Found Error Invalid pathname.
409 Conflict Error New pathname already exists.
500 Internal Server Error Error The server configuration is invalid.
Response
The response body contains the same information as the request body unless the rename fails, in which case error information is returned.
Element Type Description
error String If file or directory rename fails, a JSON array that contains details about the error.
code Unsigned integer Error code.
reason String Short description of error.
user_message String Longer description of error.
Video player

Video

×