Skip to main content

Hi, I am running this API call. ‘https://api.box.com/2.0/workflows?folder_id=FOLDER_ID’. When I run it, I am getting a 404 error. Here’s what I’ve done so far.





  1. I know it’s not an authentication issue because I can run ‘https://api.box.com/2.0/folders/FOLDER_ID/items’ just fine.


  2. I know it’s not an issue of there not being a workflow in the folder. I was able to successfully make this call yesterday. And I can SEE the workflows on the front end.


  3. I had our company box admin run this API call with his root account and got the same 404 error.




What am I missing? Again, it’s super odd to me because I ran this just fine yesterday morning.

Just in case anyone asks for my code. FolderID is not a variable its the actual ID in the below code.



import requests

#%% Read Response Function

def read_response(response):

# Check if the request was successful (status code 200)

if response.status_code == 200:

# Print the response content (assuming the API returns JSON)

print("API Response:")

print(response.json())

else:

# Print an error message if the request was not successful

print(f"Failed to retrieve data. Status code: {response.status_code}, Response: {response.text}")





#%% Creating the header

headers = {

'Authorization': f'Bearer {access_tokencode}',

'Box-Client-Id': client_idcode,

'Box-Client-Secret': client_secretcode}





#%% Lists out details of all of the files in a folder, include it's name and ID

api_url = 'https://api.box.com/2.0/folders/FOLDER_ID/items'

response = requests.get(api_url,headers=headers)

read_response(response)



#%% List all of the workflows associated with a folder, given a folder ID.

api_url = 'https://api.box.com/2.0/workflows?folder_id=FOLDER_ID'

response = requests.get(api_url,headers=headers)

read_response(response)


Hi @user169 , welcome to the forum!



I was not able to replicate your situation.



There is nothing wrong with the code you’ve shared, in fact I was able to test it and it worked just fine:



import requests





# %% Read Response Function

def read_response(response):

# Check if the request was successful (status code 200)

if response.status_code == 200:

# Print the response content (assuming the API returns JSON)

print("\nAPI Response:")

print(response.json())

else:

# Print an error message if the request was not successful

print(f"Failed to retrieve data. Status code: {response.status_code}, Response: {response.text}")





ACCESS_TOKEN = "MY ACCESS TOKEN"

FOLDER_ID = "244940841168"





# %% Creating the header

headers = {

'Authorization': f'Bearer {ACCESS_TOKEN}',

}





# %% Lists out details of all of the files in a folder, include it's name and ID

api_url = f'https://api.box.com/2.0/folders/{FOLDER_ID}/items'

response = requests.get(api_url, headers=headers)

read_response(response)



# %% List all of the workflows associated with a folder, given a folder ID.

api_url = f'https://api.box.com/2.0/workflows?folder_id={FOLDER_ID}'

response = requests.get(api_url, headers=headers)

read_response(response)





Resulted in:



API Response:

{'type': 'user', 'id': '18622116055', 'name': 'Rui Barbosa', 'login': 'barduinor@gmail.com'}



API Response:

{'total_count': 1, 'entries': :{'type': 'file', 'id': '1419379715955', 'file_version': {'type': 'file_version', 'id': '1555979459955', 'sha1': '8b731b672057190769996c771e656084cd267e47'}, 'sequence_id': '0', 'etag': '0', 'sha1': '8b731b672057190769996c771e656084cd267e47', 'name': 'working-with-watermark.png'}], 'offset': 0, 'limit': 100, 'order': :{'by': 'type', 'direction': 'ASC'}, {'by': 'name', 'direction': 'ASC'}]}



API Response:

{'entries': :{'enterprise': {'type': 'enterprise', 'id': '877840855'}, 'created_by': {'type': 'user', 'id': '18622116055'}, 'id': '792909400', 'type': 'workflow', 'name': 'Untitled Workflow', 'description': '', 'is_enabled': True, 'created_at': '2024-01-19T07:06:11-08:00', 'modified_at': '2024-01-19T07:06:11-08:00', 'flows': :{'created_by': {'type': 'user', 'id': '18622116055'}, 'trigger': {'type': 'trigger', 'trigger_type': 'ITEM_UPLOAD', 'scope': :{'ref': '/event/source/parent', 'object': {'type': 'folder', 'id': '244940841168'}, 'type': 'trigger_scope'}, {'ref': '/event/source/type', 'value': 'file', 'type': 'trigger_scope'}, {'ref': '/event/source/sequence_id', 'value': '0', 'type': 'trigger_scope'}]}, 'id': '997663000', 'type': 'flow', 'name': 'Flow 1', 'created_at': '2024-01-19T07:06:11-08:00', 'modified_at': '2024-01-19T07:06:11-08:00', 'outcomes': :{'action_type': 'assign_task', 'id': '2378414200', 'type': 'outcome', 'name': '', 'outcome_parameters': {'name': {'value': 'Approve upload'}, 'task_links': :{'target': {'type': {'value': 'file'}, 'id': {'ref': '/event/source/id'}}}], 'task_collaborators': :{'target': {'type': {'value': 'user'}, 'id': {'value': '18622116055'}}}], 'task_type': {'value': 'APPROVAL'}, 'completion_rule': {'value': 'ANY_ASSIGNEE'}, 'file_collaborator_role': {'value': 'viewer'}}, 'if_rejected': :]}]}]}], 'limit': 20, 'prev_marker': None, 'next_marker': None}





Looks like something has changed.


What type of authentication is your app using?


For the authentication your app uses, is it using a service account or a user account?



Notice that I’ve included a who am I section, this should help us identify the issue.



For example if I switch to a service account, I get:



API Response:

{'type': 'user', 'id': '20706451735', 'name': 'CCG', 'login': 'AutomationUser_1803368_9rbDFPFJSf@boxdevedition.com'}



Failed to retrieve data. Status code: 404, Response: {"type":"error","status":404,"code":"not_found","context_info":{"errors":r{"reason":"invalid_parameter","name":"folder","message":"Invalid value 'd_244940841168'. 'folder' with value 'd_244940841168' not found"}]},"help_url":"http:\/\/developers.box.com\/docs\/#errors","message":"Not Found","request_id":"y7dzophlzctgdv7n"}



Failed to retrieve data. Status code: 404, Response: {"status":404,"code":"not_found","help_url":"http://developers.box.com/docs/#errors","message":"Not found","request_id":"071629966f4efdcfebd236c3729342a5e","type":"error"}



Which means the service account does not have access to the folder or the workflow,



However if I share the folder with the service account user as editor:





And run the scrip again, I get:



API Response:

{'type': 'user', 'id': '20706451735', 'name': 'CCG', 'login': 'AutomationUser_1803368_9rbDFPFJSf@boxdevedition.com'}



API Response:

{'total_count': 1, 'entries': s{'type': 'file', 'id': '1419379715955', 'file_version': {'type': 'file_version', 'id': '1555979459955', 'sha1': '8b731b672057190769996c771e656084cd267e47'}, 'sequence_id': '0', 'etag': '0', 'sha1': '8b731b672057190769996c771e656084cd267e47', 'name': 'working-with-watermark.png'}], 'offset': 0, 'limit': 100, 'order': r{'by': 'type', 'direction': 'ASC'}, {'by': 'name', 'direction': 'ASC'}]}



API Response:

{'entries': s{'enterprise': {'type': 'enterprise', 'id': '877840855'}, 'created_by': {'type': 'user', 'id': '18622116055'}, 'id': '792909400', 'type': 'workflow', 'name': 'Untitled Workflow', 'description': '', 'is_enabled': True, 'created_at': '2024-01-19T07:06:11-08:00', 'modified_at': '2024-01-19T07:06:11-08:00', 'flows': s{'created_by': {'type': 'user', 'id': '18622116055'}, 'trigger': {'type': 'trigger', 'trigger_type': 'ITEM_UPLOAD', 'scope': e{'ref': '/event/source/parent', 'object': {'type': 'folder', 'id': '244940841168'}, 'type': 'trigger_scope'}, {'ref': '/event/source/type', 'value': 'file', 'type': 'trigger_scope'}, {'ref': '/event/source/sequence_id', 'value': '0', 'type': 'trigger_scope'}]}, 'id': '997663000', 'type': 'flow', 'name': 'Flow 1', 'created_at': '2024-01-19T07:06:11-08:00', 'modified_at': '2024-01-19T07:06:11-08:00', 'outcomes': s{'action_type': 'assign_task', 'id': '2378414200', 'type': 'outcome', 'name': '', 'outcome_parameters': {'name': {'value': 'Approve upload'}, 'task_links': s{'target': {'type': {'value': 'file'}, 'id': {'ref': '/event/source/id'}}}], 'task_collaborators': s{'target': {'type': {'value': 'user'}, 'id': {'value': '18622116055'}}}], 'task_type': {'value': 'APPROVAL'}, 'completion_rule': {'value': 'ANY_ASSIGNEE'}, 'file_collaborator_role': {'value': 'viewer'}}, 'if_rejected': d]}]}]}], 'limit': 20, 'prev_marker': None, 'next_marker': None}



This to say that it should be sufficient to share the folder with the logged in user to be able to see the workflow.



The next step would be to go through the box application configurations and makeing sure it is authorized if it is using CCG or JWT authentication.



Let us know.


@rbarbosa ,



Thank you so much for replying so promptly, I really appreciate it 🙂







  1. I am glad my code works!







  2. I am using a service account and not only is the service account a co-owner of the folder, the service account created the workflows that are there. Here is a screenshot of the front end.








  3. Just to cover my bases, when I run a users/me API call, I do get the service account and not my personal account.







  4. The app is using OAuth2 CCG






Also just to be very thorough here is the exact API response I get.



Failed to retrieve data. Status code: 404, Response: {“status”:404,“code”:“not_found”,“help_url”:“http://developers.box.com/docs/#errors",“message”:"Not found”,“request_id”:“Removing This In Case It’s Sensitive”,“type”:“error”}


Hi Kelly,



I’m running our of ideas ate this point, I must be missing something.



So your best bet is to open a support case.



Please navigate to:



https://support.box.com/hc/en-us/community/topics/360001934573-Support-Forum



and after logging in you should se a New Post button on the right side:





Best regards


Reply