-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: Uploading .json through API not working #1012
Comments
I found out that i have to end the upload in order to actually do something the upload, but im waiting 50 seconds before doing a get to list the status of files, and some files are getting canceled |
A few thoughts:
|
This is my code: def upload_file(self, zip_file_path):
file_name = zip_file_path.split("/")[-1]
with open(zip_file_path, "rb") as file:
file_content = file.read()
count = 0
uploaded = False
i = 0
while uploaded == False:
upload_job = self.create_upload_job()
upload_job_data = upload_job.json()
file_upload_job_id = upload_job_data['data']['id']
response_upload = self._requestZip(
method="POST",
uri=f"/api/v2/file-upload/{file_upload_job_id}",
body=file_content
)
print(f"{file_name} loaded. Waiting for data to be processed...")
response_end = self._request(
method="POST",
uri=f"/api/v2/file-upload/{file_upload_job_id}/end"
)
print(f"Data processing started for {file_name}")
threshold = 20
sleep(threshold)
count += threshold
while True:
response_list = self._request(
method="GET",
uri=f"/api/v2/file-upload"
)
JSON_response = response_list.json()
if JSON_response['data'][i]["status_message"] == "Partially Completed" or JSON_response['data'][0]["status_message"] == "Complete":
print(f"Successfully uploaded {file_name}")
uploaded = True
break
if JSON_response['data'][i]['status'] == 3:
print("Data processing was canceled. Error on file: " + file_name)
i += 1
break
sleep(threshold)
count += threshold
With this code, it works, but at 2nd, try. I can stick to this because is a program that efficiency is not important as is run once a month. Thanks |
If you upload that same file via the UI, does it work fine there, or is it the same behavior? |
It works fine, its just by API, everything i upload, works at second try |
I asked one of our engineers to double-check this thread, and what you're doing appears to be correct. However, without additional logs or a view of the full code snippet you're running, it will be difficult for us to help you troubleshoot further. |
Description:
Hey, im trying to upload .json through API and its giving me 202 as satus code, which means it works, but in the file ingest page, it alway stays as running, or sometime it changes to cancel, i tried uploading the same .json manually and it works fine, so it may be my code. At a first, i tried uploading a file with all the JSON, but it didnt work, so i started to mount every json manually, if the solution lets me upgrade only the zip it would be great
Are you intending to fix this bug?
"no"
Component(s) Affected:
Steps to Reproduce:
Expected Behavior:
I expect to actually upload the data correctly
Actual Behavior:
Having 202 status code, which means, data uploaded correctly, but this happens
Screenshots/Code Snippets/Sample Files:
Environment Information:
BloodHound: 6.3.0
Collector: [SharpHound version / AzureHound version]
OS: Windows 11
Browser (if UI related): [browser name and version]
Node.js (if UI related: [Node.js version]
Go (if API related): [Go version]
Database (if persistence related): [Neo4j version / PostgreSQL version]
Docker (if using Docker): 4.36.0
Additional Information:
Any additional context or information that might be helpful in understanding and diagnosing the issue.
Potential Solution (optional):
If you have any ideas about what might be causing the issue or how it could be fixed, you can share them here.
Related Issues:
If you've found related issues in the project's issue tracker, mention them here.
Contributor Checklist:
The text was updated successfully, but these errors were encountered: