Hey,
im missing a autotranlate all components and all language buttons on the ui, so i tried to use the api but i ran into following error:
The documenttion said that i could transfer form data as json in a curl, but it does not get processed from the api.
The component has no error and is not locked.
This is my test script:
$data='{"mode":"translate","filter_type":"nottranslated","auto_source":"mt","component":"","engines":"google-translate","threshold":"90"}'
curl \
--data-binary "$data" \
-H "Content-Type: application/json" \
-H "Authorization: Token MY_USER_TOKEN" \
https://myweblateurl.com/api/translations/testproject/testcomponent/de_DE/autotranslate/
Response:
{"detail":"Failed to process autotranslation data!"}
(note: i suggest to answer with its locked if its locked and not with process data failing)
When i use form data, it works:
curl \
-X POST \
-F 'mode=translate' \
-F 'filter_type=nottranslated' \
-F 'auto_source=mt' \
-F 'engines=google-translate' \
-F 'threshold=90' \
-H "Authorization: Token MY_USER_TOKEN" \
https://myweblateurl.com/api/translations/testproject/testcomponent/de_DE/autotranslate/
Doc:
CURL JSON example:
https://docs.weblate.org/en/latest/api.html#passing-parameters-examples
Autotranslate:
https://docs.weblate.org/en/latest/api.html#post--api-translations-(string-project)-(string-component)-(string-language)-autotranslate-
Engines should be an array in JSON, the documentation is wrong here. So, it should be "engines":["google-translate"].
I will improve the error handling to report this correctly.
ahhh okay thank you very much! ill give it a try asap.
that would answer my next question on how to send multiple engines, i tried comma seperated but ther eis no info if it worked/got accepted or not :)
Thank you for your report; the issue you have reported has just been fixed.
Most helpful comment
Engines should be an array in JSON, the documentation is wrong here. So, it should be
"engines":["google-translate"].I will improve the error handling to report this correctly.