dify icon indicating copy to clipboard operation
dify copied to clipboard

Tool cannot call post request correctly

Open anthonylee1994 opened this issue 11 months ago • 2 comments

Self Checks

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

Dify version

1.0.0

Cloud or Self Hosted

Cloud

Steps to reproduce

Image

My swagger doc

{
  "openapi": "3.0.0",
  "info": {
    "title": "Property Auction API",
    "version": "1.0.0",
    "description": "API for managing property auctions and contacts"
  },
  "servers": [
    {
      "url": "http://rails-property-auction.kaului.com/"
    }
  ],
  "paths": {
    "property_auctions": {
      "get": {
        "summary": "List property auctions",
        "tags": ["Property Auctions"],
        "parameters": [
          {
            "name": "name",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by property name (case-insensitive)"
          },
          {
            "name": "usage",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by property usage"
          },
          {
            "name": "gross_floor_area_min",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Minimum gross floor area"
          },
          {
            "name": "gross_floor_area_max",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Maximum gross floor area"
          },
          {
            "name": "saleable_area_min",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Minimum saleable area"
          },
          {
            "name": "saleable_area_max",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Maximum saleable area"
          },
          {
            "name": "open_price_min",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Minimum open price"
          },
          {
            "name": "open_price_max",
            "in": "query",
            "schema": {
              "type": "number"
            },
            "description": "Maximum open price"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 10
            },
            "description": "Number of records to return"
          }
        ],
        "responses": {
          "200": {
            "description": "List of property auctions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/PropertyAuction"
                  }
                }
              }
            }
          }
        }
      }
    },
    "contacts": {
      "post": {
        "summary": "Create a new contact",
        "tags": ["Contacts"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ContactInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Contact created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Contact"
                }
              }
            }
          },
          "422": {
            "description": "Validation errors",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "errors": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "PropertyAuction": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "usage": {
            "type": "string"
          },
          "gross_floor_area": {
            "type": "number"
          },
          "saleable_area": {
            "type": "number"
          },
          "open_price": {
            "type": "number"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ContactInput": {
        "type": "object",
        "required": ["name", "tel"],
        "properties": {
          "name": {
            "type": "string"
          },
          "tel": {
            "type": "string"
          }
        }
      },
      "Contact": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "tel": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      }
    }
  }
}

✔️ Expected Behavior

Response contact

❌ Actual Behavior

404 not found

anthonylee1994 avatar Mar 05 '25 02:03 anthonylee1994

The 404 status code indicates that the endpoint you're trying to reach is not found. Based on the Swagger documentation you provided, the correct path for the 'contacts' POST request should be /contacts. Ensure that the URL you are using in your request matches this path exactly.

Additionally, verify that the server URL is correct and that the endpoint is properly configured on the server. If the server URL is http://rails-property-auction.kaului.com/, the full URL for the POST request should be http://rails-property-auction.kaului.com/contacts.

Make sure that the request body is formatted correctly as per the ContactInput schema, which requires name and tel fields. If the issue persists, check the server logs for more detailed error messages that might provide further insights.

To continue talking to Dosu, mention @dosu.


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

dosubot[bot] avatar Mar 05 '25 02:03 dosubot[bot]

The 404 status code indicates that the endpoint you're trying to reach is not found. Based on the Swagger documentation you provided, the correct path for the 'contacts' POST request should be /contacts. Ensure that the URL you are using in your request matches this path exactly.

Additionally, verify that the server URL is correct and that the endpoint is properly configured on the server. If the server URL is http://rails-property-auction.kaului.com/, the full URL for the POST request should be http://rails-property-auction.kaului.com/contacts.

Make sure that the request body is formatted correctly as per the ContactInput schema, which requires name and tel fields. If the issue persists, check the server logs for more detailed error messages that might provide further insights.

To continue talking to Dosu, mention @dosu.

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

But this API is working correctly.

curl --location 'https://rails-property-auction.kaului.com/contacts' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Anthony",
    "tel": "12345678"
}'

anthonylee1994 avatar Mar 05 '25 02:03 anthonylee1994

Forgot to change the Swagger URL to https

anthonylee1994 avatar Mar 06 '25 05:03 anthonylee1994