I am having problems error handling code when deleting a file from box.com using Box API. The code establishes a connection to Box.com via JSON.
client.file(file_id=99999999999).delete()
When I run the command, the Box APIs uses HTTP status codes to communicate if a request has been successfully processed or not. This is what I see in PyCharm:
Error output
How do I use this error response (the red text in the bottom of the screen to handle errors so I can do something like this:
try:
client.file(file_id=xxxxxxxxxx).delete()
except 404:
print('error 404 occurred')
except 405:
print('error 405 occurred')
Thanks
#xaleel
I have tried this:
config = JWTAuth.from_settings_file(JSONFile)
client = Client(config)
try:
client.file(file_id=99999999999).delete()
except BoxAPIException as e:
print(e.status)
The error returned is:
Traceback (most recent call last):
File "C:\Temp\Box\Test\Test.py", line 20, in
except BoxAPIException as e:
NameError: name 'BoxAPIException' is not defined. Did you mean: 'BaseException'?
I have also tried "BoxException". Is this case sensitive? where can I look to see the correct possible name to use? Sorry I am not a programmer and really new to Python. I just set myself this challenge to learn!
Related
I am using Autodesk Revit and have been trying to implement the Design Automation API. I have been successful in trying out the sample, modify-your-model tutorial where the dimensions of a window are altered. However the example code is not executing perfectly anymore and it displays an internal server error message(error code 500). The error console claims that some parameter in the workItem is missing. The code worked again on the morning of 14th March again, but by noon it started showing the same error. The error log on the web page and console are given below respectively.
My question is, has the Autodesk OSS server been down for some time now or is it some fault from my side? Please help me out.
P.S. The same code worked perfectly before. I have not edited anything. Yes, I did try changing the Client ID and Client Secret and also update the ngrok address every 2hours.
Sincerely
Error list
-Failed to load resource: the server responded with a status of 500 (Internal Server Error)
-No webpage was found for the web address: http://localhost:3000/api/forge/designautomation/workitems
error in debugger
-fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HM76OJJ532MV", Request id "0HM76OJJ532MV:00000002": An unhandled exception was thrown by the application.
System.Net.Http.HttpRequestException: The server returned the non-success status code 400 (Bad Request).
More error details:
{
"url": [
"Error converting value \"http://aa025317d1f2.ngrok.io /api/forge/callback/designautomation?id=76m1z2sw7uQi-jtAYzYvgA&outputFileName=20210314024133_output_revit_sample_file.rvt\" to type 'System.Uri'. Path 'url', line 1, position 2376."
],
"workItem": [
"A value for the 'workItem' parameter or property was not provided."
]
}
As suggested in the comments there is a space in the ngrok url posted to the workitem:
http://aa025317d1f2.ngrok.io /api/forge/callback/designautomation?id=76m1z2sw7uQi-jtAYzYvgA&outputFileName=20210314024133_output_revit_sample_file.rvt
I have a text file which contains multiple random URL's.
Example: https://5SnczRo6sk3hWl=10pfmNzxmNZ7f.geVxQ25XIQ%ic/%2O.nrw
While sending it to chrome, for some urls I'm receiving mentioned error however for some it is working properly. (My aim is very simple: Send URL to browser ,check its output and then close the browser.)
PFB Code:
url = open ('URL_DB_new.txt','r')
url_rpt = url.read().split("\n")
for link in url_rpt:
driver = webdriver.Chrome(executable_path=r'D:\Software\chromedriver\chromedriver.exe')
print("link: ", link)
driver.get(link)
time.sleep(3)
driver.quit()
PFB Error:
Selenium Error
Any suggestion on how to handle this exception or remove it?
I am getting a 404 error when trying to access a file metadata with Google Drive Api, files.get method.
I've tried to reproduce the error using the same user and the same fileID, from the Api test page: https://developers.google.com/drive/api/v3/reference/files/get
But I can't reproduce the error. From this page I get a 200 response and I get the metadata I need (file name, etc.) That means the FileID is correct and the file does exist
According to Google the 404 error can be due to insufficient permissions (I don't think this is the case, in my code I am using https://www.googleapis.com/auth/drive which I understand includes access to metadata). Or else the file does not exist, which is also not the case.
I don't know what else to try. Here's my simple Python code:
#GET THE FILES LIST - THIS WORKS PERFECTLY:
theFiles = drive_service.files().list(pageSize=1000,q="trashed=false and mimeType != 'application/vnd.google-apps.folder'",orderBy="quotaBytesUsed desc, name, modifiedTime desc",fields="files(id,name,modifiedTime,quotaBytesUsed,starred,webViewLink, parents)").execute()
dicFiles = theFiles.get('files',[])
#GET METADATA
for item in dicFiles:
parentID=item.get('parents',[0])
#HERE I GET THE 404 ERROR
metadata= drive_service.files().get(fileId=parentID).execute()
Error:
https://www.googleapis.com/drive/v3/files/%5B%271uP0WhJXtjHBSnBb4KS80GexG9P5OLH-p%27%5D?alt=json returned "File not found: ['1uP0WhJXtjHBSnBb4KS80GexG9P5OLH-p'].">
Ok, I found the problem.
item.get('parents',[0]) wasn't returning a string, but a list.
I replaced that by item['parents'][0] and now it's working.
How to fix status code 409 for translate job.
There are two types of problems I am facing.
1. Sometimes API returns error status code 409(conflict)
2. Sometimes it continuously gives in progress status and never completes or fails even.
Once any of the above error occurs, any subsequent job requests starts failing with error code 409.
We are trying node js API for translating job using following code.
let translateResult = derivativesAPI.translate(job, { 'xAdsForce': true }, forgeSvc.requestOAuth2TwoLeggedOBJ(), accessToken);
First try to delete manifest for the stuck/pending request file,
If that doesn't works , last option is to delete the bucket with pending/stuck translation request and then try again.
As per documentation, the 409 means:
The request conflicts with a previous request that is still in progress
As you mentioned a previous request failed, but is pending on our system and causes this conflict. Is that happening consistently with a file? Or random? When it fails (or hangs), what's the manifest? Finally, can you share a problematic URN?
EDIT: the file is working now and we'll keep investigating this.
I have two orchestrations One of them is used as an error handler for the other orchestration, and is getting failed messages from it. I have set this up in BAM. The problem is when a file fails in the receive port I don't get any useful information in the Activity Search. Only that something has been registered. Data ex from BAM:
ActivityID: 2738a492-04c7-4887-9ff3-6902f435bda4
ErrorCode:
ErrorDesc:
Filename:
Progress Error: Handled
TransactionId:
rcvPort:
sndPort:
In the tracking profiler I use the properties from the errorReporter. Ex ErrorReport.FailureCode. The file gets moved as it should by the Error handler orchestration.
Does someone now what I'm doing wrong?
Is it possible to get any information when a file fails in the receive stage?
Mostly I need the filename and the error code/desc. (the Progress Error is a progress activity I have created).
I worked it out. For some reason I couldn't trace it to bam if I made progress dimension for the messages. When I just stored the plain data it worked ok.