Box CLI to Accept Custom Terms of Service
AnsweredI am using the Box CLI with a PowerShell script to get users and folders. It worked in the sand box but now I'm working in Prod and I have to accept the terms of service. Before adding the --accept flag the error tells me I need to pass in accept or reject. Once I add the flag the api command gives me a 404 Not Found error. I do have the ToS ID.
Here is my command: box terms-of-service:set-user-status $TOSID --accept
Please help. Thank you.
-
Thanks for responding, . I'm working with Marc on this, so I can provide the full error text that we're seeing below. Any insight on this would be greatly appreciated!
"
box : Unexpected API Response [404 Not Found | dedavug55tetn2hy.0hvhgg6e9l8mi5riupgcimki1tu] not_found - Not Found
"
-
In this case, the 404 may indicate a permissions issue; the account you're making the API call as through the CLI might not have access to view the Terms of Service. Here are a few questions that might help shed some light on what's going on:
- Which account should be accepting the ToS, the service account or some other user? Which user are you making the API call as?
- If you run box terms-of-service:get $TOS_ID with the same ID, do you still get a 404?
- If you get a developer token from the Box Developer Console and make the calls from the CLI using --token $DEVELOPER_TOKEN, do you still get a 404?
-
Thanks, . We realized that there were two values being returned for $TOSID, so after putting them in a loop, we also added a condition to specify tso_types not equal to "external", as shown below. This gave us positive results, either updating the TOS for users or creating it if they had not accepted previously.
foreach($boxUser in $boxUsersObject) {
$TOS = box terms-of-service --json
$TOSstring = $TOS | Out-String
$TOSobjects = ConvertFrom-Json -InputObject $TOSstring
foreach ($TOSobject in $TOSobjects) {
if ($TOSobject.tos_type -ne "external") {
$TOSID = $TOSobject.id
box terms-of-service:set-user-status $TOSID --accept --as-user $BoxUser.id }
Please sign in to leave a comment.
Comments
5 comments