Created
August 5, 2020 02:50
-
-
Save dkeightley/1a499a1f2b2c18108bf38a7ad1935875 to your computer and use it in GitHub Desktop.
Function to create box folder and file requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function box-request() | |
{ | |
_BEARER_TOKEN="<box app token>" | |
_FOLDER_NAME=$1 | |
echo -n "Creating ${_FOLDER_NAME}" | |
_FOLDER_ID=$(curl -sX POST https://api.box.com/2.0/folders \ | |
-H "Authorization: Bearer ${_BEARER_TOKEN}" \ | |
-H 'Content-Type: application/json' \ | |
-d '{ | |
"name": "'${_FOLDER_NAME}'", | |
"parent": { | |
"id": "109957074997" | |
} | |
}' | jq -r '.id') | |
echo "... done" | |
echo -n "Creating file request" | |
_FOLDER_REQUEST_URL=$(curl -s "https://app.box.com/app-api/file-request-web/file-request?folderId=${_FOLDER_ID}" \ | |
-H "Authorization: Bearer ${_BEARER_TOKEN}" \ | |
-H 'Content-Type: application/json' | jq -r '.url') | |
echo "... done" | |
echo "You can access the box folder here: https://app.box.com/folder/${_FOLDER_ID}" | |
echo "File request URL: https://app.box.com${_FOLDER_REQUEST_URL}" | |
echo "https://app.box.com${_FOLDER_REQUEST_URL}" | pbcopy | |
echo "File request URL copied to clipboard!" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Setup:
_BEARER_TOKEN
variable.bashrc
or.zshrc
source ~/.zshrc
etcbox-request <folder>