GPT actions, Accept header. HTTP Calling

Hi everyone,

I have a problem with calling an API. I’ve used the correct schema from the API but i still have an issue with the header. Here is my schema:

openapi: 3.0.1
info:
  title: Författningssamling
  description: >-
    Boverket tillgängliggör här informationen i Boverkets författningssamling i form av ett API. Författningssamlingen
    innehåller Boverkets föreskrifter och allmänna råd. Tjänsten innehåller övergripande information om alla Boverkets
    författningar med hänvisning till motsvarande pdf-fil. För ett urval av författningarna tillhandahåller tjänsten
    också innehållet i författningen.


    Ta del av användarvillkor samt läs mer om API-tjänst för Boverkets författningssamling på boverket.se. Länk: https://www.boverket.se/sv/om-boverket/publicerat-av-boverket/oppna-data
  version: "1.0"
servers:
  - url: https://api.boverket.se/forfattningssamling
paths:
  /{version}/forfattningar:
    get:
      summary: Hämta författningslista
      description: Hämtar information om författningar som finns i Boverkets författningssamling.
      operationId: getOrdinanceList
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
            enum:
              - v1
        - name: typ
          in: query
          schema:
            type: string
        - name: titel
          in: query
          schema:
            type: string
        - name: forfattning
          in: query
          schema:
            type: string
        - name: grundforfattning
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Successful response
  /{version}/forfattningar/sok:
    get:
      summary: Sök efter författningsinnehåll
      description: Söker med fritext i författningarnas innehåll.
      operationId: searchOrdinanceContent
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
            enum:
              - v1
        - name: text
          in: query
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
  /{version}/forfattningar/{id}:
    get:
      summary: Hämta författningsinformation
      description: Hämtar information om vald författning.
      operationId: getOrdinanceInfo
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
            enum:
              - v1
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Successful response
  /{version}/forfattningar/{id}/innehall:
    get:
      summary: Hämta författningsinnehåll
      description: Hämtar strukturerat innehåll från en vald författning.
      operationId: getOrdinanceContent
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
            enum:
              - v1
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: paragraf
          in: query
          schema:
            type: string
        - name: filter
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Successful response
  /{version}/forfattningar/{id}/innehall/html:
    get:
      summary: Hämta författningsinnehåll som HTML
      description: Hämtar innehåll formaterat som HTML från en vald författning.
      operationId: getOrdinanceContentHtml
      parameters:
        - name: version
          in: path
          required: true
          schema:
            type: string
            enum:
              - v1
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: paragraf
          in: query
          schema:
            type: string
        - name: filter
          in: query
          schema:
            type: string
      responses:
        "200":
          description: Successful response
      headers:
        Accept:
          description: Accepted response body format
          required: true
          schema:
            type: string
            enum:
              - application/json
              - application/xml
            default: application/json

And the error i get:

{
  "response_data": {
    "Message": "Undefined Accept header parameter"
  },
  "status_code": 400,
  "action_id": "g-3a2872941c965a103729b6e71387aa554ebc16b3"
}

What is it that im missing out?

Thank you!

EDIT:
The schema works on Swagger and other API testing platforms.

Try moving it to the parameters section. E.g.,

    - name: Accept
      in: header
      schema:
      ...

See: Describing Parameters

It does not work.
I’ve also tried:

        "200":
          description: Successful response
          content:
            application/json:
              schema:
                type: object

And it still doesnt work.

The really frustrating part is that it works fine in Swagger.

I’m going to suggest you do the following,

Copy your schema into a new action and delete the action which isn’t working.

It appears that sometimes (especially when there are errors) schemas can be locked into some weird state. Creating a new action is sometimes enough to get it working again.

I spent more time than I care to admit the other night “debugging” a perfectly valid schema, only to have it just work inside a new action.

I can’t promise that will work, but it can only help.

2 Likes

Wow - this literally seems to be magic trick. I just did it with my GPT which I had long given up on due to some issue with the API-Key transmission. Copied the existing schema into a brand new GPT and voila, it worked.

1 Like

Turn it off and turn it on it again.

Did you get it to work @alfailyhussein ?

Testing the API on the Boverket API service seems to also not work properly, so maybe this is client side?

No, unfortunently.

I also tried the advice by @elmstedt but i still get an issue with the header. Have you got it to work?

I contacted Boverket but they cant see an issue on their side, neither have they blocked OpenAI or GPT requests. I also get a good response when i use Swagger and other API test sites.

1 Like

I still get the accept header issue as well, despite it working on Postman etc.

And my other saved GPTs with or without actions no longer access their knowledges bases. Endless errors.

With previously working Actions I get:

“I can’t directly call external APIs or perform network requests”

On the Team plan by the way.

As I am not a developer I am giving up on this endeavor for now.

Well, I made some progress after using Claude Sonnet to look over the schema - the accept header issue seems to have been solved.

The new issue is that Chat GPT comes back and says the content accessed through the Boverket API is too large to handle (regardless which GET). Even if single documents, which are text-only and really quite small, are specified.

At this rate Boverket will publish their very own LLM before the API integration with Chat GPT through Actions works.