Reputation: 1
I was trying to use the Microsoft Translator API in my Client app (Nintex Automation Cloud) using JSON format and I always get stuck to this error whenever I try to execute a request.
{"error":{"code":400074,"message":"The body of the request is not valid JSON."}}
Here's my JSON structure and I tried a LOT of re-structuring, but I still get the same error.
I hope I could get some help from this amazing community. Please I really need your expertise! It's my first time to ask question here, so feel free if you need more details from me. I'll be waiting for your answer. Thank you in advance!
{
"swagger": "2.0",
"info": {
"description": "Microsoft Translator",
"version": "1.0",
"title": "Microsoft Translator"
},
"x-ntx-render-version": 2,
"host": "api.cognitive.microsofttranslator.com",
"basePath": "/translate",
"schemes": [
"https"
],
"produces": [
"application/json"
],
"paths": {
"/v3": {
"post": {
"summary": "Translate Text",
"description": "Translate Text",
"parameters": [
{
"in": "body",
"name": "body",
"x-ntx-summary": "",
"schema": {
"$ref": "#/definitions/TextToTranslate"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/TranslatedText"
}
}
},
"security": [
{
"apikey": []
}
]
}
}
},
"securityDefinitions": {
"apikey": {
"type": "apiKey",
"name": "Ocp-Apim-Subscription-Key",
"in": "header"
}
},
"definitions": {
"TextToTranslate": {
"type": "object",
"additionalProperties": false,
"properties": {
"text": {
"type": "array",
"x-ntx-summary": "Text to Translate",
"items": {
"type": "string"
}
},
"to": {
"type": "string",
"x-ntx-summary": "Target Language",
"description": "Provide the Language code you would like to translate to. For example set es for Spanish or en for English.",
"default": "en"
}
}
},
"TranslatedText": {
"type": "object",
"properties": {
"translations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"to": {
"type": "string"
}
}
}
}
}
}
}
}
I was trying to fix the schema parameter because I believe that's where the error about. I tried mixing the items, object and array parameters, and to be honest I only have 1 month experience with this so bare with me if I don't have deeper knowledge on this and might be using wrong terminology, but please feel free to educate or enlighten me. Thank you so much guys!
TextToTranslate": {
"type": "object",
"additionalProperties": false,
"properties": {
"text": {
"type": "array",
"x-ntx-summary": "Text to Translate",
"items": {
"type": "string"
}
},
"to": {
"type": "string",
"x-ntx-summary": "Target Language",
"description": "Provide the Language code you would like to translate to. For example set es for Spanish or en for English.",
"default": "en"
}
}
},
Upvotes: 0
Views: 96