I’m trying make GPT post a structured data into an endpoint.
Because the structure is dynamic, it has to first fetch the structure, and then make the post. This means that I can’t properly define the request body inside the Open API specification, but I need to make a generic one.
Every time GPT tries to insert it, it gets the structure well, but it uses the “params”, instead of the “body”. This results in an error from the engine, where the request doesn’t match the schema, so it tries again with no parameters at all.
This is the schema:
/api/tables/{tableId}/rows:
post:
summary: Inserts a new row in the table
description: Inserts
operationId: insertRowInTable
parameters:
- in: path
name: tableId
required: true
schema:
title: Table ID
type: string
format: uuid
description: The Table ID. Extracted from table.id.
requestBody:
required: true
description: A JSON object containing the columns to insert
content:
application/json:
schema:
type: object
example: '{ "properties": { "Name": "My name", "Other Property": 7, ... } }'
properties:
properties:
type: object
description: Key-value pairs. The key is the Name of the property, and the value is what will be inserted. The value
must match the type of the property.
additionalProperties:
oneOf:
- type: string
description: String. For Select, Title and Text.
- type: number
description: Number. For Number.
- type: boolean
description: Boolean. For Checkbox.
- type: string
description: String. For Date. Must be in ISO 8601 format.
format: date
- type: array
description: Array of strings. For MultiSelect.
items:
type: string
responses:
"204":
description: Row successfully inserted. No content is returned.
"422":
description: Invalid request. You will need to retry the same request after fixing the errors.
content:
application/json:
schema:
$ref: "#/components/schemas/ErrorValidation"
And this is what GPT does on debug mode:
"method": "post",
"path": "/api/tables/{tableId}/rows",
"operation": "insertRowInTable",
"operation_hash": "...",
"is_consequential": true,
"params": {
"tableId": "01eba820-123d-4041-859e-8d768ecb5126",
"body": {
"properties": {
"Name": "New headache",
"Rate Intensity 1-10": 8,
"Category": "Headache"
}
}
}
And it receives this, which is correct:
{ "response_data": "UnrecognizedKwargsError: body" }
What am I missing? How can I do a POST request with the correct body? Is this an OpenAPI issue?