Visual FoxPro Box: Delete Folder

Back to Index

Move a folder to the trash. The recursive parameter must be included in order to delete folders that aren't empty. This example deletes the folder w/ id = 47885473705. An empty 204 response will be returned upon successful deletion. An error is thrown if the folder is not empty and the ‘recursive’ parameter is not included.

Documentation: https://developer.box.com/reference#delete-a-folder

CURL Command

curl https://api.box.com/2.0/folders/47885473705?recursive=true \
-H "Authorization: Bearer BOX_ACCESS_TOKEN" \
-X DELETE

Visual FoxPro Example

LOCAL loRest
LOCAL lnSuccess
LOCAL lnBTls
LOCAL lnPort
LOCAL lnBAutoReconnect
LOCAL loSbResponseBody

loRest = CreateObject('Chilkat_9_5_0.Rest')

*  URL: https://api.box.com/2.0/folders/47885473705?recursive=true
lnBTls = 1
lnPort = 443
lnBAutoReconnect = 1
lnSuccess = loRest.Connect("api.box.com",lnPort,lnBTls,lnBAutoReconnect)
IF (lnSuccess <> 1) THEN
    ? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
    ? loRest.LastErrorText
    RELEASE loRest
    CANCEL
ENDIF

loRest.AddHeader("Authorization","Bearer BOX_ACCESS_TOKEN")

loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestNoBodySb("DELETE","/2.0/folders/47885473705?recursive=true",loSbResponseBody)
IF (lnSuccess <> 1) THEN
    ? loRest.LastErrorText
    RELEASE loRest
    RELEASE loSbResponseBody
    CANCEL
ENDIF

RELEASE loRest
RELEASE loSbResponseBody