Root_Folder ID

Discussion in 'LiquidFiles General' started by LRSpartan, Jul 27, 2021.

  1. LRSpartan

    LRSpartan New Member

    Joined:
    Apr 30, 2019
    Messages:
    13
    Likes Received:
    2
    With the LF team switching the root_folder ID from 'root' to a set of random characters, I needed a way to capture this so that I can batch upload to the folder. I use the following Windows batch script to get a list of shares, then query the shares for the id field. I use JQ to process the json. I couldn't figure out a way to get the share.id and root_folder.id on the same line. Any help with that would be great. I hope this help.

    ***Beginning***

    PAUSE
    curl -X GET -H "Content-Type: application/json" --user TopSecretAPIKey:x https://my.somefancywebsite.com/admin/shares/ >C:\curl\shares.json

    jq --raw-output ".shares[].id" shares.json>shares_out.txt

    for /F "tokens=*" %%A in (C:\curl\shares_out.txt) do (

    curl -k -X GET -H "Content-Type: application/json" --user TopSecretAPIKey:x https://my.somefancywebsite.com/shares/%%A>>users.json

    )

    jq --raw-output ".share.id, .share.root_folder.id" users.json>root_folder.txt

    PAUSE
    ***End***
     
  2. David

    David Administrator
    Staff Member

    Joined:
    Dec 1, 2015
    Messages:
    781
    Likes Received:
    31
    I am not sure if the jq works in the windows environment absolutely same way like in the linux.
    In linux shell it could be like this:

    Code:
    curl -k -X GET --user "SecretAPIkey:x" -H "Content-Type: application/json" https://lf.domain.com/shares/shareabc | jq -c '({share_id: .share.id, root_id: .share.root_folder.id})' 
    output should be something like this:
    Code:
    {"root_id":"0d6d9c41-8352-410b-832e-d70967b9f7b7","share_id":"shareabc"}
     
    LRSpartan likes this.
  3. LRSpartan

    LRSpartan New Member

    Joined:
    Apr 30, 2019
    Messages:
    13
    Likes Received:
    2
    Thanks David! For Window$, all I did was replace the single quotes with double quotes and it worked.

    jq -c "({share_id: .share.id, root_id: .share.root_folder.id})" users.json


     

Share This Page