openapi not working on my gpts

Version ie v5.11.67

Environment: Docker

Checklist

  • The problem could not be replicated on the demo.
  • Yes, I searched, nothing like my problem.
  • Unfortunately, there is nothing useful in the logs.

Describe the bug

I’ve created my own gpts in the chatgpt.
I created an action
I have created and added a token.
the scheme used:

openapi: 3.0.3
info:
  title: Invoice Ninja API
  version: '1.0'
servers:
  - url: server
paths:
  /api/v1/invoices:
    get:
      summary: Gauti sąskaitų sąrašą
      operationId: getInvoices
      parameters:
        - name: client_id
          in: query
          description: Filtruoti sąskaitas pagal kliento ID
          required: false
          schema:
            type: string
        - name: page
          in: query
          description: Puslapio numeris
          required: false
          schema:
            type: integer
        - name: per_page
          in: query
          description: Sąskaitų skaičius puslapyje
          required: false
          schema:
            type: integer
        - name: include
          in: query
          description: Įtraukti susijusius duomenis (pvz., klientus)
          required: false
          schema:
            type: string
        - name: X-Requested-With
          in: header
          description: Naudojamas nurodyti XMLHttpRequest
          required: true
          schema:
            type: string
            example: XMLHttpRequest
      responses:
        '200':
          description: Sąskaitų sąrašas
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        number:
                          type: string
                        amount:
                          type: number
                        balance:
                          type: number
                        status_id:
                          type: integer
                        client_id:
                          type: string
                        created_at:
                          type: integer
                        updated_at:
                          type: integer
                        due_date:
                          type: string
                          format: date
                        invoice_date:
                          type: string
                          format: date
                  meta:
                    type: object
                    properties:
                      pagination:
                        type: object
                        properties:
                          total:
                            type: integer
                          count:
                            type: integer
                          per_page:
                            type: integer
                          current_page:
                            type: integer
                          total_pages:
                            type: integer
      security:
        - ApiKeyAuth: []
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-TOKEN

The problem:

[debug] Calling HTTP endpoint

{
  "domain": "server",
  "method": "get",
  "path": "/api/v1/invoices",
  "operation": "getInvoices",
  "operation_hash": "603369ae403381720326a09c425634e602263cd9",
  "is_consequential": false,
  "params": {}
}

[debug] Response received

{
  "response_data": {
    "message": "Malformed JSON payload.",
    "error": "Invalid JSON data provided"
  },
  "status_code": 400,
  "action_id": "g-d65a584cb3af9d0ef183afaa7f6d520d76d8b461"
}

[debug] Failed Outbound Call

{
  "text_raw": {
    "response_data": {
      "message": "Malformed JSON payload.",
      "error": "Invalid JSON data provided"
    },
    "status_code": 400,
    "action_id": "g-d65a584cb3af9d0ef183afaa7f6d520d76d8b461"
  },
  "http_status": 400,
  "domain": "server",
  "method": "get",
  "path": "/api/v1/invoices",
  "operation": "getInvoices",
  "operation_hash": "603369ae403381720326a09c425634e602263cd9",
  "is_consequential": false,
  "params": {}
}

I’ve tried many schemes, all based on the same error:

  "response_data": {
    "message": "Malformed JSON payload.",
    "error": "Invalid JSON data provided"
  }

while curl works fine.

PS C:\my> Invoke-RestMethod -Method Get -Uri "server/api/v1/invoices" -Headers @{"X-API-TOKEN" = $token}

data
----
{@{id=VolejRejNm; user_id=VolejRejNm; project_id=;.....

It could be a chatgpt openapi problem, maybe someone can advise/help.

Hi,

I’m not sure, in case it’s helpful here’s what ChatGPT suggests…

Thanks for posting all this detail — you’re definitely on the right track. Based on your description and the fact that curl (or Invoke-RestMethod) works fine but the OpenAPI action via GPT returns a 400 “Malformed JSON payload”, here’s what’s likely happening:


:magnifying_glass_tilted_left: Root Cause

You’re sending a GET request but OpenAPI (and ChatGPT’s GPT action system) is likely adding a default Content-Type: application/json header with an empty body, which Invoice Ninja doesn’t expect for GET requests.

Laravel (which Invoice Ninja is built on) will throw a Malformed JSON payload error if:

  • Content-Type: application/json is present but the body is empty or invalid JSON.
  • This often happens with GET requests that should not have a body at all.

:white_check_mark: Solutions

:white_check_mark: 1. Remove Content-Type: application/json for GET requests

Unfortunately, ChatGPT’s action platform (via OpenAPI) may automatically add this for all requests.

To work around this, explicitly declare requestBody: false or leave it undefined for your GET method.

In OpenAPI 3.0.3, you should not define a requestBody for GET:

get:
  summary: Gauti sąskaitų sąrašą
  operationId: getInvoices
  parameters:
    ...
  responses:
    ...
  # 👇 DO NOT include requestBody here

:white_check_mark: 2. Ensure headers are defined properly

Make sure you’re not forcing Content-Type in headers:

parameters:
  ...
  - name: X-Requested-With
    in: header
    required: true
    schema:
      type: string
      example: XMLHttpRequest

Don’t add Content-Type header at all for GET.


:white_check_mark: Sanity Check: Try Minimal Working Version

Try simplifying your GET request in the OpenAPI schema to:

paths:
  /api/v1/invoices:
    get:
      summary: Get invoice list
      operationId: getInvoices
      parameters:
        - name: X-API-TOKEN
          in: header
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-TOKEN
security:
  - ApiKeyAuth: []

Then slowly add back your other query parameters.


:white_check_mark: Optional Debug

If GPT’s API logs allow you to inspect full request headers, confirm whether it’s sending:

Content-Type: application/json

If so, this is the problem — and it must be removed for GET requests to Invoice Ninja.


:white_check_mark: TL;DR Fix

  • Do not use requestBody in GET requests.
  • Avoid sending Content-Type: application/json for GET.
  • Ensure only query parameters and headers are used.
  • GPT/OpenAPI may be misbehaving — try with minimal schema first.

Let me know if you want help rewriting your full schema to avoid this!

1 Like

it would be great if someone could rewrite the whole scheme for openapi v3.1.0. Yet gpts requires a schema smaller than 1Mb, and endpoints must be under 30.