AzureTranslator HTTP Request return The body of the request is not valid JSON

Describe the issue/error/question

Hello,

I had this issue quite some time (I gave up on it for a week and now I’m back) and it’s already been asked over on AzureTranslator HTTP Request return The body of the request is not valid JSON - Microsoft Q&A
I was pretty positive the problem was on Microsoft end but I’m not sure anymore.

I’m new to MS Azure and trying to use the translator resource via HTTP Request Node. I tried out all the node settings but it kept getting rejected by MS Api?

I tried the settings on webhook.site and it works no problem

I also tried to access the resource via Azure Active Directory? by connecting the account but that gave me an error using n8n OAuth2

Please share the workflow

Using parameters:

Using Raw:

There were other approaches but I already delete them without a second thought since they didn’t work… these 2 are the only ones I kept

Information on your n8n setup

  • n8n version: 0.156.0 ( I’m not sure if this is normal but every time I update n8n under the image section by the three dots then pull, it made a new image which then I need to make a new container then reimport the workflows from the previous version. Because of this hassleness I only update when I feel like it )
  • Database you’re using (default: SQLite): None
  • Running n8n with the execution process [own(default), main]: own?
  • Running n8n via [Docker, npm, n8n.cloud, desktop app]: Docker

Hi @ReMiKU, The error message you have shared would indeed suggest an error coming from Microsoft and it’s not super obvious what they are expecting here.

I took a look at the forum post you have linked and the response simply seems to consist of Python code rather than a pointer at what you might need to change about the request.

Unfortunately I have not used this API before nor do I have a particularly great understanding of Microsoft Azure’s auth concept. So as a next step I’ll take a closer look into how to authenticate with MS Azure’s cognitive services before I’ll be able to check your specific request.

Hello @MutedJam,
Following the python response, they replied being not familiar n8n as well and encourage me to bring the issue here, in case it may be an error in n8n instead.

I’ve read their documentation on using azure translate which proved to be a relatively easy process that is if it’s by code approach. I tried to implement it in n8n way which should be working. So I’m really dumbstruck as to why it’s getting rejected.

I really appreciate the help! It’s been plaguing me for days scratching my head to the point of hair loss (not much) :weary: Here’s some of the resource documentation I refer to:

(I really don’t like how they structure their documentation…)

1 Like

Hey @ReMiKU,

So after completely misunderstanding the authentication option for this service for the last days I finally got it to work :tada:! And the good news is once it’s understood is much simpler than expected but it took me ages to read through their distributed documentation.

I think you were already on the right track here, but it seems Microsoft only accepts arrays of objects in the body rather than a single object (meaning the error message was very misleading for me).

Here is my working HTTP Request node for reference:

Example Workflow

My credentials just define the Ocp-Apim-Subscription-Key header:
image

Key (used in the credentials) and region (used in the HTTP header) are taken from this screen in Azure (sorry it’s all in German, I couldn’t find a simple option to change the language just for this portal - but I imagine the icons might still help):

You’ll need to update both key and region on your end for this to work.

I hope this helps! Let me know if you still run into trouble here.

1 Like

Bruh… @MutedJam,

I did that once before having the key as header auth but then it didn’t work out (probably because of my other parameters) but then I also figure where the sub-region would go since it should be in the header as well… damn you saved me! Tysm!!! :star_struck: :tada:

1 Like

Thanks for this solution @MutedJam. I was trying the same approach for the azure form recognizer, but it does not work. Have passed the region as well.

Error:

“error”:{“code”:“401”,“message”:“Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource.”}}

Hey @Yuvaraj_Selvaraj,

Welcome to the community :raised_hands:

Can you open a new thread and fill out the template provided?

As a starting point that error is the other service telling you that the subscription is invalid or the region / api is wrong. I would start by checking that as it isn’t an n8n generated error and something we don’t really have control over.

Thanks, Jon. Will create a new thread. I agree that it is not n8n error. Need help on the configuration as the similar configuration works for translare