-
Notifications
You must be signed in to change notification settings - Fork 286
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
Question about POST request to /api/stored-libraries/ in python #1393
Comments
Hi @EmilienPer02, Thank you for reaching out. The A common issue we’ve observed in similar cases is a malformation in the library YAML file. If the file is not sensitive, could you share it with us? This would help us investigate the specific issue and identify any malformed parts. Regards |
Hello, My script is roundly the following url="https://exemple.com/api/stored-libraries/" headers={ 'accept': 'application/json', 'Referer': 'https://exemple.com', 'Authorization': 'Bearer ', 'X-Csrftoken': '<CSRF_TOKEN>', 'Content-Disposition': 'attachment; filename="tiber-eu-2018.yaml"'} cookies={'csrftoken':<CSRF_TOKEN>,'sessionid':<SESSION_ID>} data=None If I remove 'Content-Disposition' from headers, I have an other issue ({"detail":"Missing filename. Request should include a Content-Disposition header with a filename parameter."} |
Hi @EmilienPer02, Thanks for sharing your script! I believe the issue lies in how the file is being sent. Additionally:
Here’s an example of how your script could look: import requests
TOKEN = "<your auth token>"
url = "https://example.com/api/stored-libraries/upload/"
headers = {
"Authorization": f"Token {TOKEN}",
"Content-Disposition": 'attachment; filename="tiber-eu-2018.yaml"'
}
file_path = "tiber-eu-2018.yaml"
with open(file_path, "rb") as file:
response = requests.post(url, headers=headers, data=file)
print(f"Status Code: {response.status_code}")
print(f"Response: {response.json()}") I am expecting something like this to work. You should receive an empty response with status code If the issue persists, feel free to reach out. |
Thank for your help. Could you help me by:
Thank |
Hello,
I'm trying to upload a custom library using your API .
My script is in python and uses "requests".
When I'm trying to send the file, I have the error "Missing filename" that requests me to add a Content-Disposition in header.
When I add it, I have a invalidLibraryFileError.
In the frontend, I'm able to send the file so the file is good.
Do you have a POC script in python using requests to send a library via your API to /api/stored-libraries/ via a POST request?
Thank
The text was updated successfully, but these errors were encountered: