Skip to main content
Known Participant
Jun 21, 2023 9:18 PM UTC

How I run a Box API in Postman with multiple iterations using a CSV file?

How I can use a CSV file to upload different variables for a Box API call in Postman?

    10 replies

    smartoneinok Box
    Senior Developer Advocate
    Jun 21, 2023 10:14 PM UTC

    Hello,

    Can I have more clarification on your question? Are you saying that you want to use a csv to update multiple objects (files, folders, users, etc) in Box in one call? Or are you saying, instead of typing information in the json body of the Postman window, you’d want to use a csv?

    Thanks,
    Alex, Box Developer Advocate

    Translate
    user711Author
    Known Participant
    Jun 21, 2023 10:22 PM UTC

    Hi,

    Yes I want to use the collection runner in Postman in order to use CSV file that will update the path parameter, I am using the “https://{{api.box.com}}/2.0/folders/:folder_id/metadata/enterprise/securityClassification-6VMVochwUWo” API call and I want to use a CSV file to update the “:folder_id” using the collection runner in Postman.

    Translate
    Amr Salama Khalil
    smartoneinok Box
    Senior Developer Advocate
    Jun 22, 2023 5:59 PM UTC

    Hello,

    I have never used that functionality in Postman, so I can’t really speak to it.

    However, you can use the Box CLI along the bulk commands feature to achieve the same thing. Its also probably easier with the CLI!

    I highly recommend going through the CLI quick start.

    Translate
    user711Author
    Known Participant
    Jun 22, 2023 8:06 PM UTC

    Hi Alex,

    I tries to use Box CLI but is doesn’t have bulk command for assigning “Classification” even as metadata, it only supports “Metadata Cascade Policies”., really appreciate if you can guide me how to do it in CLI. I agree with that CLI is easier.

    Best Regards

    Translate
    Amr Salama Khalil
    smartoneinok Box
    Senior Developer Advocate
    Jun 22, 2023 9:46 PM UTC

    Ah! I see. Let me investigate this a bit further and report back.

    Translate
    smartoneinok Box
    Senior Developer Advocate
    Jun 23, 2023 2:40 PM UTC

    I have reached out to the CLI team to see about getting the classifications piece documented/supported.

    In the meantime, let me work on a workaround for you.

    Translate
    kberdychowski Box
    Box Employee
    Jun 26, 2023 12:20 PM UTC

    It looks like you want to add specific metadata template to a folder. You can check the bulk operation of adding metadata to a folder:

    maybe it will help you.

    Translate
    user711Author
    Known Participant
    Jun 26, 2023 10:42 PM UTC

    Thank you for sharing this command but unfortunately it only works on single folder, once I add the “–bulk-file-path”, I get the following error “I tired with 4 entries”.

    "4 entries failed!

    Entry 1 (
    id=213735351436
    ) failed with error:
    Metadata must be in the form key=value


    Entry 2 (
    id=213799010963
    ) failed with error:
    Metadata must be in the form key=value


    Entry 3 (
    id=213555708197
    ) failed with error:
    Metadata must be in the form key=value


    Entry 4 (
    id=213756339231
    ) failed with error:
    Metadata must be in the form key=value

    This is the command line that I am using
    "box folders:metadata:add --bulk-file-path=C:\Users\asalama\Documents\Box\IDs.csv --template-key “securityClassification-6VMVochwUWo” --data “Box__Security__Classification__Key=Yellow Data”

    This is Metadata for Classification.

    Translate
    Amr Salama Khalil
    Box Employee
    Jun 27, 2023 8:34 AM UTC

    Hi @user711 ,

    When bulk command is executed, all params should be set in csv file. So please create the metadata.csv file based on this template:

    Id,Scope,TemplateKey,Data
    YOUR_FOLDER_ID_1,enterprise,securityClassification-6VMVochwUWo,Box__Security__Classification__Key=Yellow Data
    YOUR_FOLDER_ID_2,enterprise,securityClassification-6VMVochwUWo,Box__Security__Classification__Key=Yellow Data
    YOUR_FOLDER_ID_3,enterprise,securityClassification-6VMVochwUWo,Box__Security__Classification__Key=Yellow Data
    

    Please replace YOUR_FOLDER_ID_X with the corresponding folder Ids.

    Then run te following command:
    box folders:metadata:add --bulk-file-path ./metadata.csv

    Please let us know if it helped.

    Translate
    user711Author
    Known Participant
    Jun 27, 2023 3:30 PM UTC

    Yes I tried this last night and it worked, thank you.

    Translate
    Amr Salama Khalil