cloudflare / cloudflare/cloudflare-python
`script_upload.py` example: Returns `cloudflare.APIStatusError`
- Vorherrschende Sprache
- Python
- Sterne
- 506
- Forks
- 148
- Ø Merge
- 3 Std. 15 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
### Confirm this is a Python library issue and not an underlying Cloudflare API issue.
- [x] This is an issue with the Python library
### Describe the bug
When running the `script_upload.py` script, I get:
```
cloudflare.APIStatusError: Error code: 415 - {'result': None, 'success': False, 'errors': [{'code': 10001, 'message': 'Content-Type must be one of: application/javascript, text/javascript, multipart/form-data'}], 'messages': []}
```
This indicates to problems:
1. The `except` block should expect an exception of type `APIStatusError`, not `BadRequestError`
2. The `tuple` to upload the files is buggy
### To Reproduce
Run
```bash
CLOUDFLARE_API_TOKEN="..." CLOUDFLARE_ACCOUNT_ID="..." uv run script_upload.py
```
### Code snippets
```Python
```
### OS
macOS
### Python version
3.13
### Library version
4.2.0
Beitragsleitfaden
Rechercherichtung
Öffne das Beispiel script_upload.py und führe es mit den dokumentierten Umgebungsvariablen CLOUDFLARE_API_TOKEN und CLOUDFLARE_ACCOUNT_ID aus. Überprüfe den vom except-Block behandelten Ausnahmetyp und das zum Hochladen der Dateien verwendete Tupel. Die Aufgabe ist abgeschlossen, wenn das Beispiel die gemeldeten Content-Typen ohne den 415-Fehler akzeptiert und APIStatusError korrekt behandelt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 48/100