Struggling to create a custom action that does http post with x-www-form-urlencoded data

Hi !
Working on building a custom gpt that can make a call to an external api. The external api requestes the data to be submitted to it with content type as application/x-www-form-urlencoded

Here’s how my simple OpenAPI spec file (in YAML ) looks like:

openapi: 3.0.1
info:
  title: Test HTTP Post
  description: Test HTTP Post requests with form submit
  version: 1.0.0
servers:
  - url: https://kallipr-fake-petstore.free.beeceptor.com/api
    description: Example API server
paths:
  /data:
    post:
      operationId: submitFormData
      summary: Submit form data
      description: Endpoint to submit data using application/x-www-form-urlencoded content type.
      requestBody:
        required: true
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                first_name:
                  description: First name of the user
                  type: string
                last_name:
                  description: Last name of the user
                  type: string
      responses: 
        '200':
          description: Success response
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '400':
          description: Bad Request
        '401':
          description: Unauthorized

While trying the preview - the debug http section shows that this is how it looks like

{
  "domain": "kallipr-fake-petstore.free.beeceptor.com",
  "method": "post",
  "path": "/data",
  "operation": "submitFormData",
  "operation_hash": "a81858e22c18caacec8090ab9747b404f8b5bece",
  "is_consequential": true,
  "params": {}
}

I have used this prompt:

Submit test form data with first name as Hello and last name as world

I am using vscode editor for authoring the YAML. OpenAPI extensions say this is a valid YAML and can generate correct http POST requests from inside of vscode.

What am I doing wrong in this YAML for GPT Actions not sending the body?

I tried to pass data to the Action using requestBody in many different ways and none worked, just passing data on query, headers or path worked to me.

I can could get the application/json post request body to work. Just struggling to get the application/www-form-url-encoded to work

I’m having this issue too. I can make the request successfully via Postman. Is www-form-url-encoded just not supported currently? The API I’m using only accepts that format for the request body schema.

What did you do to make it submit the data with POST via JSON? I am struggling with it up till now.

Hey mate, the following YAML schema will work for application/json custom action:

---
openapi: 3.2.0
info:
  title: API For a Pet Store
  description: OpenAPI spec creating new pets at a petstore
  version: v1.0.0
servers:
- url: <your url endpoint goes in here>
paths:
  "/pets":
    post:
      description: Create a new pet
      operationId: addPets
      parameters:
      - in: query
        name: api_key
        description: Authentication API Key for the request
        required: true
        schema:
          type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Pet'
            examples:
              dog:
                summary: A representation of a dog
                value:
                  name: dog
                  type: dog
                  color: brown
                  age: 5
components:
  schemas:
    Pet:
      type: object
      properties:
        name:
          type: string
        type:
          type: string
        color:
          type: string
        age:
          type: integer

use Put Update Data. Post create New Data en call endpoint, aplication objet JSON.

For my GPT, the API I’m trying to interact with only accepts www-form-urlencoded data, it seems. So that means I’m out of luck, right?

As of now, looks like it.
I will have to see if there’s a way to raise a support ticket with the OpenAI team.

1 Like