Move Folder (or Resource) in EDX Drive

API Endpoint: move_folder

Moves an existing folder or resource to a different location within a private collaborative workspace’s EDX Drive.

Important

An API Key is required for ALL private workspace activities

If you wish to move a folder or resource to the root level of the EDX Drive, then use the value root for parent_id

Parameter Definitions

Parameter name

Description

Required Field

workspace_id

The name or ID of workspace that you wish to add a folder to

Required

new_parent_id

The ID of the destination folder

Required

item_id

The ID of the folder or resource you wish to move

Required

Note

In the event that a resource or array of resources are not found, items will be added to the returned output named “items_not_moved”.

Example 1: Move Single Item on EDX Drive

Attention

  • Add the "User-Agent": parameter within the headers of the API request

  • Set "User-Agent": to the value "EDX-USER"

  • python
  • output
import requests
headers = {
    "EDX-API-Key": 'YOUR-API-KEY-HERE',
    "User-Agent": "EDX-USER"
}

data = {
    "workspace_id": 'YOUR-WORKSPACE-NAME-OR-ID-HERE',
    "new_parent_id": 'ID-OF-DESTINATION-FOLDER-HERE',
    "item_id": 'ID-OF-FOLDER-OR-RESOURCE-HERE'
}

url = 'https://edx.netl.doe.gov/api/3/action/move_folder'

r = requests.post(
    url, # URL to API endpoint
    headers=headers, # Headers dictionary
    data=data, # Dictionary of data params
)
print (r.json())
print("End results")
{
    'help': 'https://edx.netl.doe.gov/api/3/action/help_show?name=move_folder',
    'success': True,
    'result': {
        'folder_id': 'FOLDER-ID-HERE',
        'workspace_id': 'WORKSPACE-ID-HERE',
        'workspace_name': 'demo-workspace-test'
        'items_moved': [moved_items]
    }
}

Example 2: Move Multiple Items on EDX Drive

Attention

  • Add the "User-Agent": parameter within the headers of the API request

  • Set "User-Agent": to the value "EDX-USER"

  • python
  • output
import requests
headers = {
    "EDX-API-Key": 'YOUR-API-KEY-HERE',
    "User-Agent": "EDX-USER"
}

data = {
    "workspace_id": 'YOUR-WORKSPACE-NAME-OR-ID-HERE',
    "new_parent_id": 'ID-OF-DESTINATION-FOLDER-HERE',
    "item_id": ['ARRAY-OF-IDS-FOR-FOLDER-AND-OR-RESOURCE-HERE']
    #Example of array ['id1', 'id2', 'id3']
}

url = 'https://edx.netl.doe.gov/api/3/action/move_folder'

r = requests.post(
    url, # URL to API endpoint
    headers=headers, # Headers dictionary
    data=data, # Dictionary of data params
)

print (r.json())
print("End results")
{
   'help': 'https://edx.netl.doe.gov/api/3/action/help_show?name=move_folder',
     'success': True,
     'result': {
        'folder_id': 'FOLDER-ID=-HERE',
        'workspace_id': 'WORKSPACE-ID-HERE',
        'workspace_name': 'demo-workspace-test',
        'items_moved': [moved_items]}

}