From 2ec4d365e65fbb19ac9f1ddcd5da11adcb059721 Mon Sep 17 00:00:00 2001 From: fpagny Date: Wed, 30 Apr 2025 18:53:46 +0200 Subject: [PATCH 1/2] feat(genapi): add json body invalid troubleshooting --- .../troubleshooting/fixing-common-issues.mdx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pages/generative-apis/troubleshooting/fixing-common-issues.mdx b/pages/generative-apis/troubleshooting/fixing-common-issues.mdx index 1b7fbd2484..27b0cffd8d 100644 --- a/pages/generative-apis/troubleshooting/fixing-common-issues.mdx +++ b/pages/generative-apis/troubleshooting/fixing-common-issues.mdx @@ -26,6 +26,19 @@ Below are common issues that you may encounter when using Generative APIs, their - `15k` tokens context window on `H100` Instances - `128k` tokens context window on `H100-2` Instances +## 400: Bad Request - Invalid JSON body + +### Cause +- You provided a JSON body that does not follow [standard JSON structure](https://datatracker.ietf.org/doc/html/rfc8259), therefore your request cannot be analyzed. + +### Solution +- Verify the JSON body you send is valid: + - You can store your content in a file with `.json` extension (eg. named `file.json`), and open it with an IDE such as VSCode or Zed. Syntax errors should display if there are present. + - You can copy your content in a JSON formatter tool or linter available online, that will identify errors. + - Usually, most common errors include: + - Missing or unecessary quotes `"`, `'` or commas `,` on properties name and string values. + - Special characters that are not escaped, such as line break `\n` or backslash `\\` + ## 403: Forbidden - Insufficient permissions to access the resource ### Cause @@ -234,4 +247,4 @@ This snippet will output the model response, which is `4`. ### Debugging silent errors - For cases where no explicit error is returned: - Verify all fields in the API request are correctly named and formatted. - - Test the request with smaller and simpler inputs to isolate potential issues. \ No newline at end of file + - Test the request with smaller and simpler inputs to isolate potential issues. From faa2db8b827cd738a95c5e2d40449e003f86b54a Mon Sep 17 00:00:00 2001 From: SamyOubouaziz Date: Mon, 5 May 2025 11:00:38 +0200 Subject: [PATCH 2/2] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Néda <87707325+nerda-codes@users.noreply.github.com> --- .../generative-apis/troubleshooting/fixing-common-issues.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pages/generative-apis/troubleshooting/fixing-common-issues.mdx b/pages/generative-apis/troubleshooting/fixing-common-issues.mdx index 27b0cffd8d..1f6a986d79 100644 --- a/pages/generative-apis/troubleshooting/fixing-common-issues.mdx +++ b/pages/generative-apis/troubleshooting/fixing-common-issues.mdx @@ -29,11 +29,11 @@ Below are common issues that you may encounter when using Generative APIs, their ## 400: Bad Request - Invalid JSON body ### Cause -- You provided a JSON body that does not follow [standard JSON structure](https://datatracker.ietf.org/doc/html/rfc8259), therefore your request cannot be analyzed. +- You provided a JSON body that does not follow the [standard JSON structure](https://datatracker.ietf.org/doc/html/rfc8259), therefore your request cannot be analyzed. ### Solution - Verify the JSON body you send is valid: - - You can store your content in a file with `.json` extension (eg. named `file.json`), and open it with an IDE such as VSCode or Zed. Syntax errors should display if there are present. + - You can store your content in a file with the `.json` extension (eg. named `file.json`), and open it with an IDE such as VSCode or Zed. Syntax errors should display if there are any. - You can copy your content in a JSON formatter tool or linter available online, that will identify errors. - Usually, most common errors include: - Missing or unecessary quotes `"`, `'` or commas `,` on properties name and string values.