Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Box CLI to Accept Custom Terms of Service

Answered
New post

Comments

5 comments

  • mwiller

     Can you post the full error message you're seeing from the CLI?  That would be helpful in order to troubleshoot what might be going on with the request the CLI is making for you.

    0
    Comment actions Permalink
  • awpaxton

    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

    "

     

    0
    Comment actions Permalink
  • mwiller

     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?
    0
    Comment actions Permalink
  • awpaxton

    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 }

    0
    Comment actions Permalink
  • mwiller

     Great, I'm glad to hear it's working for you now!

    0
    Comment actions Permalink

Please sign in to leave a comment.