POST/GET data from GPTs (plugin) to server-side API

I’ve been struggling with this as well. If anyone has been able to get multipart POST requests working, please post your schema.

Strangely I am not even able to do a basic POST with a basic, plain text parameter.

GPT does execute the custom action, whether it is formatted as YAML or JSON, but when I check the posted RequestBody data at my server’s end, it’s always empty.

GPT says “this is the data I’m gonna send”, let’s say foo:bar and hello:world - but my server (PHP) says empty data received.

It works by the query setting (from the URL), but not for the body.

Weird?

I burned 3 times my limit today (about 120 affords made) and no single solution did work.

1 Like

Same here! Tried all I could but I m not finding the way yet

Yup, I am doing something wrong… but what?

With more than 35 years of experience in web- / app- / api-development, I can’t even get the post to work, lol.

I tried everything, like posting in the (request)body, sending parameters in the header and pushing cookies (with the required data) to the endpoint on my server… all are delivered empty.

I also create a test set-up in an isolated development environment. Once I post a parameter there, using the exact same code as in the OpenAI environment, all works well.

The moment I call the exact same JSON / YAML based API code @OpenAI, nothing works.

For now I solved it by sending the two required parameters in the URL query.

That is okay, as it is a closed experiment, but it’s weird I can not even send a simple key ↔ value pair.

The GPT says it is sending it, I can see what parameters and values it is sending (in the dropdown menu when “it is talking to your server”, but the server says “thanks for the call, why didn’t you send any data?”.

1 Like

For file uploads, I’ve got this working with a very small example (still need to test this for larger files/binaries):
https://community.openai.com/t/unable-to-upload-files-from-a-custom-chatgpt-session-via-an-api-action

TL;DR - Have it break the base64 encoded file into 500 character chunks and send those chunks to an endpoint that will reassemble them into the file.

1 Like

Even a simple text-string is not send / posted to my server.

I am fully aware of the 500 chrs limit, but my “whole” string is just 4 characters.

It’s kind of an #ID I have to send from the GPT to my server. The server fetches that #ID, queries it’s own SQL by that #ID and returns the data.

But the #ID is never recieved (GPT says it is sending it, like fetch_id : 4821 but it never reaches my server).

So there must be something wrong at my servers end, which is just a .php script… trying to fetch everything that is incoming.

{
  "openapi": "3.1.0",
  "info": {
    "title": "Get data",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://xxx.com"
    }
  ],
  "paths": {
    "/xxx": {
      "get": {
        "operationId": "send_id",
        "parameters": [
          {
            "name": "the_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    }
  }
}

This works, because the_id is send in the query, like https://xxx.com/foo/?the_id=3429.

But when I set the method to post and “in” to requestBody | header | cookie it is never seen.

2 Likes

@logankilpatrick we would love to know if support for multipart POST actions is on the cards or whether file upload as an action is something that is being held back purposefully. :pray:

2 Likes

Hi all, do we have any news on this from someone?

1 Like

I got a POST request to send data. I think the key step was to define the requestBody object type in my action schema

 "/post-expense-data/expense-data": {
      "post": {
        "summary": "Send the transactions",
        "operationId": "postExpenseData",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["transactions"],
                "properties": {
                  "transactions": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Transaction"
                    },
                  "description": "An array of transaction objects."
                }
              }
            }
                }
              }
        },

A simpler example would be something like(untested)

        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties":  {
                   "$ref": "#/components/schemas/Transaction"
                 }
}

But I needed to pass an array of objects to my BE.