400000 One of the request inputs is not valid. error for vanilla js

Volkan Ger 6 Reputation points
2022-08-24T22:42:55.353+00:00
Hello all, I'm having trouble understanding what's wrong with this simple request. Any ideas?  
  
const endpoint = 'https://api.cognitive.microsofttranslator.com/translate'  
const location = 'eastus2'  
const body =  [{ "text":"What is wrong with me?" }]  
const resp = await fetch(endpoint, {  
    method: 'post',  
    params: {  
          'api-version': '3.0',  
          'from': 'en',  
          'to': ['de', 'it']  
        },  
    headers: {  
          'Ocp-Apim-Subscription-Key': subscriptionKey,  
          'Ocp-Apim-Subscription-Region': location,  
          'Content-type': 'application/json',  
        },  
    body: body  
    })  
const data = await resp.json()  
console.log(JSON.stringify(data)  
return new Response(JSON.stringify(data))  
Azure Translator
Azure Translator
An Azure service to easily conduct machine translation with a simple REST API call.
340 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Volkan Ger 6 Reputation points
    2022-08-24T23:59:16.003+00:00
    1 person found this answer helpful.
    0 comments No comments