Box CLI and Metadata Template with Dropdown Single Selection

Hi @matt.riley

I tried using Box CLI to apply metadata that has dropdown with a single selection

Template Name: Record Retention Classification - Creation Date Trigger
Template Key: recordRetentionClassificationCreationDateTrigger
Key: retentioncode
Key: ADMN-002 - Reference Information Related to Projects and Events

CLI that I used: box folders:metadata:add 1051425259330 --template-key recordRetentionClassificationOtherDateTrigger --data “retentioncode=ADMN-002 - Reference Information Related to Projects and Events” --as-user=19154187332

Error that I get:
Unexpected API Response [404 Not Found | 46bpsqhg41zbyrqj.0d6797ce64c9554460589c48527cffcf9] not_found - Not Found

Need to know the wrong step from my side.

Hi @user711!

There are a couple of things that might cause a 404 here. My first guesses would be:

  • The folder ID you specified (1051425259330) doesn’t exist or isn’t accessible by the user ID provided
  • The “retentioncode” field might need to be “retentionCode” with a capital “C” (I see that happen quite a bit because Box will automatically capitalize the words in the field ID if your display name has spaces between the words).

Hope that gets you on the right track!

I spoke a little too soon! I conducted a couple of quick tests, intentionally making the errors I described above.

It turns out that errors in the template name or the field name generate more detailed error messages. The only way I could replicate the generic 404 that you mentioned was to supply a folder that didn’t exist or that my user didn’t have permissions to.

I’d recommend looking at the folder ID and permissions first.

Thanks for you prompt answer, you got me on the right direction, I should have used “files” instead of “folder” as this metadata should be assigned on the level of the file so I modified the command.

Now I get a different error
box files:metadata:add 1051425259330 --template-key recordRetentionClassificationOtherDateTrigger --data “retentioncode=ADMN-002 - Reference Information Related to Projects and Events” --as-user=19154187332

Unexpected API Response [400 Bad Request | ftyqizhg4qiv55lx.095e91388330b004d4caa1af444d1fe96] bad_request - Request contains invalid parameters.

That looks like the error I get when my field name is incorrect. Are you sure that your field name is all lowercase? My guess would be that it’s actually “retentionCode”.

You are 100% correct :slight_smile: , Thank you

1 Like

Sorry @matt.riley to bother you again but I am getting the same error for this command line while i have made sure of all attributes

Template Key: recordRetentionClassificationCreationDateTrigger
Key: retentionCode
Key: ADMN-001 – Temporary Records

CLI: box files:metadata:add 1078392343973 --template-key recordRetentionClassificationCreationDateTrigger --data “retentionCode=ADMN-001 - Temporary Records” --as-user=19154187332

Error: Unexpected API Response [400 Bad Request | 8fl4e1hg64ratjdt.06ad5c9b8688a12674d449a19ba766087] bad_request - Request contains invalid parameters.

Hey @user711, I had to dig into this one a bit deeper to figure out what was going on. You’ve uncovered a bug here, but the good news is that there’s a really easy fix you can do on your side.

The problem is, your Drop Down option of ADMN-001 - Temporary Records is using an emdash character between the “001” and “Temporary”. It looks like this was probably accidental (and REALLY hard to spot) because the other template’s field didn’t have that emdash character.

The bug is that we’re not properly parsing that character when it gets passed to our service. We’ll log a ticket and get it fixed. In the meantime though, you can simply edit the field name in the Admin Console to replace the emdash with a dash. (I know the page says you can’t edit it, but you can safely edit the name, don’t worry!)

I should add - when you edit the field, I’d recommend typing it out rather than copy/paste. The copy/paste thing is how those emdash characters typically find their way in.