400 Bad Request Error When Calling DeepL API in Mendix

0
Hi everyone,I am developing an English-Japanese translation application in Mendix Studio Pro, and I am encountering a "400 Bad Request" error when attempting to call the DeepL API.The Issue:When I trigger the "Translate" button, the microflow fails. My console logs show the following request:⁠{"text": ["hello"], "target_lang": "JA"}⁠However, I am receiving a 400 Bad Request error from the API.Environment Details: Mendix Studio Pro Version: [Insert your version, e.g., 10.15.0] Endpoint: ⁠https://api-free.deepl.com/v2/translate⁠ Log excerpt:⁠Response content for POST request to https://api-free.deepl.com/v2/translate HTTP/1.1 400 Bad Request content-type: application/json⁠What I have tried: I have verified my Authentication header. I have checked the JSON structure being passed to the Call REST activity.Could someone please help me understand if there is a formatting issue in how I am sending this request, or if there is a specific way Mendix handles the JSON mapping for the DeepL API? Any guidance would be greatly appreciated!This project is for a job interview, I might be able to hire those who help me with the project, if I get the job.
asked
2 answers
0

Hi,

A 400 Bad Request from DeepL usually means the request format is invalid rather than an authentication issue.


A few things to check:

  • Verify that you're sending the request as POST with Content-Type: application/json.
  • Make sure you're calling the correct endpoint (https://api-free.deepl.com/v2/translate for the free API key).
  • Double-check that your Authorization header is in the correct format (DeepL-Auth-Key <your-api-key>).
  • Enable REST consume trace logging in Mendix to inspect the exact request body being sent. Sometimes the JSON object shown in the debugger differs slightly from what is actually transmitted.


Your JSON:

{
  "text": ["hello"],
  "target_lang": "JA"
}

looks valid, so the issue is likely with the headers or how the request is being serialized.


Could you also share:

  • Your Call REST configuration (headers and body).
  • The exact response body returned by DeepL (it usually contains a more descriptive error message than just 400 Bad Request).


That will help narrow down the root cause.


Kindly mark this as the accepted answer if it helps.

answered
0

Hi Cheh,


I always suggest to use Postman (postman.com) or other REST/API tools to validate all consumed or offered API calls first before using them in Mendix.


Once you see them working in your Postman collection, you can easy implement them into Mendix.


Also testing against your offered REST/API calls is easy with Postman and shows potential risks or issues with the date itself or authentication.


Many greetings,

Timo

answered