Can't import any tools which are POST apis that have requestBody #7664

Closed
opened 2026-02-21 18:21:43 -05:00 by yindo · 4 comments
Owner

Originally created by @yuhua6379 on GitHub (Jan 11, 2025).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.15.0

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

The simple json schema below won't be accepted. 👇👇

{
  "openapi": "3.0.2",
  "info": {
    "title": "Test API",
    "description": "Test API description",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.example.com"
    }
  ],
  "paths": {
    "/common/cache_set": {
      "post": {
        "description": "设置缓存",
        "operationId": "缓存-set",
        "responses": {
          "200": {
            "description": "Successful response"
          }
        },
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "key": {
                    "title": "Key",
                    "type": "string"
                  },
                  "value": {
                    "title": "Value",
                    "type": "string"
                  }
                },
                "title": "CacheSetRequest",
                "type": "object"
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

Dify then raised this error.
image

But when I simplely removed 'requestBody' and made it like this.👇👇

{
  "openapi": "3.0.2",
  "info": {
    "title": "Test API",
    "description": "Test API description",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.example.com"
    }
  ],
  "paths": {
    "/common/cache_set": {
      "post": {
        "description": "设置缓存",
        "operationId": "缓存-set",
        "responses": {
          "200": {
            "description": "Successful response"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

My submitting was successful!
image

@crazywoola @laipz8200
I thinks POST-api tools are very important. Please fix this bug soon.🥰🥰🥰🥰🥰🥰🥰

✔️ Expected Behavior

POST-api tools can be submited successfully.

Actual Behavior

Can't submit any POST-api tools with 'requestBody'.

Originally created by @yuhua6379 on GitHub (Jan 11, 2025). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.15.0 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce The simple json schema below won't be accepted. 👇👇 ```json { "openapi": "3.0.2", "info": { "title": "Test API", "description": "Test API description", "version": "1.0.0" }, "servers": [ { "url": "https://api.example.com" } ], "paths": { "/common/cache_set": { "post": { "description": "设置缓存", "operationId": "缓存-set", "responses": { "200": { "description": "Successful response" } }, "requestBody": { "content": { "application/json": { "schema": { "properties": { "key": { "title": "Key", "type": "string" }, "value": { "title": "Value", "type": "string" } }, "title": "CacheSetRequest", "type": "object" } } } } } } }, "components": { "schemas": {} } } ``` Dify then raised this error. ![image](https://github.com/user-attachments/assets/0f8ba054-163d-4d16-903a-d317b4e6e840) But when I simplely removed 'requestBody' and made it like this.👇👇 ```json { "openapi": "3.0.2", "info": { "title": "Test API", "description": "Test API description", "version": "1.0.0" }, "servers": [ { "url": "https://api.example.com" } ], "paths": { "/common/cache_set": { "post": { "description": "设置缓存", "operationId": "缓存-set", "responses": { "200": { "description": "Successful response" } } } } }, "components": { "schemas": {} } } ``` My submitting was successful! ![image](https://github.com/user-attachments/assets/4250d00d-07b4-45c6-8e65-ff5762fffdd3) @crazywoola @laipz8200 I thinks POST-api tools are very important. Please fix this bug soon.🥰🥰🥰🥰🥰🥰🥰 ### ✔️ Expected Behavior POST-api tools can be submited successfully. ### ❌ Actual Behavior Can't submit any POST-api tools with 'requestBody'.
yindo added the 🐞 bug🔨 feat:tools labels 2026-02-21 18:21:43 -05:00
yindo closed this issue 2026-02-21 18:21:43 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 11, 2025):

To resolve the issue of not being able to submit POST API tools with a 'requestBody' in Dify 0.15.0, you can add an empty parameters attribute to the POST method. This workaround allows the schema to pass validation while maintaining the requestBody functionality in actual API calls. Here is an example of how you can modify your schema:

paths:
  /common/cache_set:
    post:
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              properties:
                key:
                  title: "Key"
                  type: "string"
                value:
                  title: "Value"
                  type: "string"
              title: "CacheSetRequest"
              type: "object"
      responses:
        "200":
          description: "Successful response"

This should resolve the error related to the invalid schema and allow you to submit your POST API tools successfully [1].

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Jan 11, 2025): <!-- Answer --> To resolve the issue of not being able to submit POST API tools with a 'requestBody' in Dify 0.15.0, you can add an empty `parameters` attribute to the POST method. This workaround allows the schema to pass validation while maintaining the requestBody functionality in actual API calls. Here is an example of how you can modify your schema: ```yaml paths: /common/cache_set: post: parameters: [] requestBody: content: application/json: schema: properties: key: title: "Key" type: "string" value: title: "Value" type: "string" title: "CacheSetRequest" type: "object" responses: "200": description: "Successful response" ``` This should resolve the error related to the invalid schema and allow you to submit your POST API tools successfully <sup>[[1]](https://github.com/langgenius/dify/issues/12456)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/6afdfb5a-e34f-46f6-9fb7-dee9aeac70ca?feedback_type=other)</sup>
Author
Owner

@yuhua6379 commented on GitHub (Jan 11, 2025):

@dosu I've tried dosubot's suggestion and made it like this.

openapi: "3.0.0"
info:
  title: "Cache API"
  version: "1.0.0"
servers:
  - url: http://api.example.com/v1
    description: Production server
  - url: http://staging-api.example.com/v1  
    description: Staging server
  - url: http://dev-api.example.com/v1
    description: Development server

paths:
  /common/cache_set:
    post:
      summary: "Set cache value"
      description: "Store a key-value pair in the cache"
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              properties:
                key:
                  title: "Key"
                  type: "string"
                  description: "Cache key"
                value:
                  title: "Value" 
                  type: "string"
                  description: "Cache value"
              required:
                - key
                - value
              title: "CacheSetRequest"
              type: "object"
      responses:
        "200":
          description: "Successful response"
          content:
            application/json:
              schema:
                type: "object"
                properties:
                  success:
                    type: "boolean"
                    description: "Operation success status"
                  message:
                    type: "string"
                    description: "Response message"
        "400":
          description: "Bad request"
          content:
            application/json:
              schema:
                type: "object"
                properties:
                  error:
                    type: "string"
                    description: "Error message"
        "500":
          description: "Internal server error"
          content:
            application/json:
              schema:
                type: "object"
                properties:
                  error:
                    type: "string"
                    description: "Error message"

Still, this error came out.
image

@yuhua6379 commented on GitHub (Jan 11, 2025): @dosu I've tried dosubot's suggestion and made it like this. ```yaml openapi: "3.0.0" info: title: "Cache API" version: "1.0.0" servers: - url: http://api.example.com/v1 description: Production server - url: http://staging-api.example.com/v1 description: Staging server - url: http://dev-api.example.com/v1 description: Development server paths: /common/cache_set: post: summary: "Set cache value" description: "Store a key-value pair in the cache" parameters: [] requestBody: required: true content: application/json: schema: properties: key: title: "Key" type: "string" description: "Cache key" value: title: "Value" type: "string" description: "Cache value" required: - key - value title: "CacheSetRequest" type: "object" responses: "200": description: "Successful response" content: application/json: schema: type: "object" properties: success: type: "boolean" description: "Operation success status" message: type: "string" description: "Response message" "400": description: "Bad request" content: application/json: schema: type: "object" properties: error: type: "string" description: "Error message" "500": description: "Internal server error" content: application/json: schema: type: "object" properties: error: type: "string" description: "Error message" ``` Still, this error came out. ![image](https://github.com/user-attachments/assets/80778a24-0abc-43a5-b590-a5afff4887dc)
Author
Owner

@crazywoola commented on GitHub (Jan 12, 2025):

This is already fixed in main branch, please search existing issue first and wait for next release.

@crazywoola commented on GitHub (Jan 12, 2025): This is already fixed in main branch, please search existing issue first and wait for next release.
Author
Owner

@dosubot[bot] commented on GitHub (Jan 12, 2025):

If you're still encountering errors after adding an empty parameters attribute, ensure that your OpenAPI schema is correctly formatted and adheres to the OpenAPI 3.0 specification. Here are a few things to check:

  1. YAML Formatting: Ensure that the YAML is properly formatted. Indentation errors can cause issues.

  2. Schema Validation: Double-check that all required fields and types are correctly specified in your schema. Ensure that the requestBody and responses sections are correctly structured.

  3. Error Details: Look at the specific error message provided by Dify to identify what might be causing the issue. If the error message is related to schema validation, it might provide clues on what needs to be adjusted.

  4. Server URLs: Ensure that the server URLs are correctly specified and accessible.

If these checks do not resolve the issue, it might be helpful to review the specific error message for more details on what might be causing the problem. If the error persists, consider simplifying the schema to isolate the issue, then gradually add complexity back to identify the exact cause.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Jan 12, 2025): <!-- Answer --> If you're still encountering errors after adding an empty `parameters` attribute, ensure that your OpenAPI schema is correctly formatted and adheres to the OpenAPI 3.0 specification. Here are a few things to check: 1. **YAML Formatting**: Ensure that the YAML is properly formatted. Indentation errors can cause issues. 2. **Schema Validation**: Double-check that all required fields and types are correctly specified in your schema. Ensure that the `requestBody` and `responses` sections are correctly structured. 3. **Error Details**: Look at the specific error message provided by Dify to identify what might be causing the issue. If the error message is related to schema validation, it might provide clues on what needs to be adjusted. 4. **Server URLs**: Ensure that the server URLs are correctly specified and accessible. If these checks do not resolve the issue, it might be helpful to review the specific error message for more details on what might be causing the problem. If the error persists, consider simplifying the schema to isolate the issue, then gradually add complexity back to identify the exact cause. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/1859c210-ee4d-4828-8739-4fb9dd64fd00?feedback_type=other)</sup>
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7664