API: upload translation as field instead of file
Describe the problem
A third party system can't upload translations via API because it can't provide the filename= parameter required by DRF on the file param in the POST /api/translations/(project)/(component)/(language)/file/ request to Weblate.
Solution brainstorm
Either:
- make it optional to provide a
filename=, or - add a additional form parameter (e.g.
file_content) as a alternative to thefileparam.
The filename provided is not used by Weblate.
Describe alternatives you have considered
- Additional endpoint that is not called
/api/translation/.../file/but something like/api/translation/.../update/: might be cleaner, but adds even more API surface for little benefit. - Getting the vendor of the third party system to support
filename=in their API client for form-encoded data: lot's of patience required...
Screenshots
No response
Additional context
Based on the example in the docs, I'd basically like to do the following:
curl -X POST \
-F file=<strings.xml \ # <-- note the `<` instead of `@` in front of the filename
-H "Authorization: Token TOKEN" \
http://example.com/api/translations/hello/android/cs/file/
The TRANSLATION_UPLOAD_MAX_SIZE needs to still be considered.
AFAIR it should work with the application/json content type and use {"file": ...} as the payload.
Thanks! I quickly tried it with a curl --json='{"file": "dummy data"}' -X POST /api/translation/.../file/ if that's what you mean?
Result: {"code":"parse_error","detail":"Missing filename. Request should include a Content-Disposition header with a filename parameter.","attr":null}.
The third party API client I'm working with is powerful, but it does not seem possible to wrap their generated XML data in a JSON object anyway. The double quote escaping that would be needed... 😵
Okay, we have a test that confirms that this is actually unsupported since 9c20300ee2617cbdff4ae492e3cf8cc0a40e76f1:
https://github.com/WeblateOrg/weblate/blob/fa5681bf565b6d9f2b4d08c87ab7b5832695698f/weblate/api/tests.py#L8608-L8614
Thank you for your report — the issue has now been resolved.
The fix has been merged into the repository and will be included in the upcoming Weblate 2026.10 release.
- If you encounter any issues with the fix, please comment in this thread.
- If you experience a similar but separate issue, open a new report so we can track it properly.
- If you find Weblate helpful, consider supporting its development.