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

That is fine. Simple API calls work for me as well. But has anyone succeeded in sending a user file to the server side, like an image, for example? Actually, when I chatted with ‘Configure’ chat and asked if forwarding a user image is allowed, it said it’s not :slight_smile: So, maybe it’s not supposed to work that way.

Maybe you can ask GPT to base64 encode the uploaded image, send that data as text to you API and fetch it there.

But that won’t work for binaries.

1 Like

Hey- can we connect? I’ve been reading your posts, and I’m trying to find someone who can talk me through creation of actions and the potential of them. Would be great to hear back.

Best is to talk here, so everyone with the same troubles can learn.

And I am not "that good’, I just try out an awful lot of things (until it works…).

What about passing bearer tokens to the API? Has anyone gotten that to work? It is not working for me and I am pretty sure my OpenAPI spec is correct. If anyone has an example of a working API (I am using github’s API directly), that would be greatly appreciated. Auth with Bearer tokens doesn’t seem to be working.

yup,I tried base64, binary and imageURL as well. It understands other fields in POST request but ignores file upload.

1 Like

Maybe it is sandboxed and the system doesn’t have (direct) access to it.

Who knows, in the future.

We’ve been trying this as well, but no joy yet. Can’t seem to get multipart POST requests working at all, even without the file :person_shrugging:

Having the same issue, multipart doesn’t work for sure, and when sending the image as base64 it seems that the string is truncated and I’m not getting a proper image as a result.

Only thing that can be sent is an URL in the POST request, with the ‘application/json’ header, but that doesn’t help, because I would like to use the image the user uploaded to GPT.

EDIT: it seems only the first 500 characters of the base64 string are sent.

I see your pain :slight_smile:
If OpenAI’s solution architects are reading this, please consider developing a solution where user consent is obtained for each external file upload. For instance, a prompt could appear stating, ‘An external API is requesting permission to upload your file.’ Accompany this with options like (Button: Allow) / (Button: Deny). Also, implement a graphical interface that clearly displays which file will be shared and with which domain. For example, it could show ‘MyDinner.jpg’ → being transferred to → ‘salad-eating-championship.com’.

Currently, my thought is to create a workaround using an external upload URL and guide users to an external web page to facilitate image uploads.

1 Like

So has anyone succeeded in being able to send the file the user submitted to a server??

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.