From 9eefccb880c02d14a8a3232343bea72af2797d7d Mon Sep 17 00:00:00 2001 From: Ketan <73937490+devketanpro@users.noreply.github.com> Date: Tue, 5 Nov 2024 16:56:21 +0530 Subject: [PATCH] fix api payload in Bokmal to Nynorsk Translate Macro [SDNTB-875] (#513) * fix api payload in Bokmal to Nynorsk Translate Macro [SDNTB-875] * add timeout --- server/ntb/macros/nob_NO_translate_macro.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server/ntb/macros/nob_NO_translate_macro.py b/server/ntb/macros/nob_NO_translate_macro.py index 794fe76c9..913f4dc08 100644 --- a/server/ntb/macros/nob_NO_translate_macro.py +++ b/server/ntb/macros/nob_NO_translate_macro.py @@ -9,7 +9,11 @@ def nob_NO_translate_macro(item, **kwargs): - preference_params = {k: True for k in get_user_preference_params()} + preference_params = ( + {k: True for k in get_user_preference_params()} + if get_user_preference_params() + else {} + ) token = app.config.get("OMSETT_API_TOKEN", "") @@ -36,7 +40,7 @@ def nob_NO_translate_macro(item, **kwargs): "fileType": "html", } - r = requests.post("https://nynorsk.cloud/translate", data=data, timeout=(10, 30)) + r = requests.post("https://nynorsk.cloud/translate", json=data, timeout=(10, 30)) if r.status_code == 200: item.update(r.json())