Errors with Open API schema for POST action

I’ve been trying to make a POST request over to an Airtable table and I’m stuck. I’m using the following for my Open API schema:

{
  "openapi": "3.1.0",
  "info": {
    "title": "Untitled",
    "description": "Your OpenAPI specification",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://api.airtable.com/v0/app##############"
    }
  ],
  "paths": {
    "/tbl##############": {
      "get": {
        "operationId": "getTask",
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      },
      "post": {
        "requestBody": {
          "content": {
            "application/json": {
              "records": [
                {
                  "fields": {
                    "Name": "Test",
                    "Notes": "Some info"
                  }
                }
              ]
            }
          }
        },
        "operationId": "postTask",
        "responses": {
          "200": {
            "description": "Success"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

When I ask the GPT to test postTask, it says it failed with:

“The attempt to use the postTask action encountered an error. The issue appears to be due to missing “fields” in the request body.”

I asked it to show what it sent and it responded with an empty nest {}. Is there a reason it’s not using my postTask Action? I may not be understanding this correctly but according to the Airtable documentation, to create a record (row) using curl, it would look something like:

curl -X POST https://api.airtable.com/v0/app##############/Tasks \
  -H "Authorization: Bearer YOUR_SECRET_API_TOKEN" \
  -H "Content-Type: application/json" \
  --data '{
  "records": [
    {
      "fields": {
        "Name": "Task #1",
        "Notes": "I'\''m a task"
      }
    },
    {
      "fields": {
        "Name": "Task #1",
        "Notes": "I'\''m a task"
      }
    }
  ]
}'

I’m not 100% sure why Airtable has two of the same “fields” here. I tried doing the same with my schema but I ended up with the same issue as before.

Am I forming this schema correctly to make the POST request? What am I missing?

1 Like