core_user
core_user

Reputation: 172

Ocelot Failed to match Route configuration for upstream path

Hello Now I am trying to use Ocelot gateway Normally I have one api in different server such as

https://server_domain.net/kpiDashboardApi

without gateway if I send request directly to below link , it works

https://server_domain.net/kpiDashboardApi/Report/DocumentTypeCounts

I want to reach endpoint in this api from Ocelot in my local I use below configuration json

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/kpiDashboardApi/Report/DocumentTypeCounts",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "https://server_domain.net/kpiDashboardApi",
          "Port": 443
        }
      ],
      "UpstreamPathTemplate": "/Report/DocumentTypeCounts",
      "UpstreamHttpMethod": [ "Post" ]
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:5001"
  }
}

when U send request to https://localhost:5001/kpiDashboardApi/Report/DocumentTypeCounts

it return 404 and as error return in console below

warn: Ocelot.DownstreamRouteFinder.Middleware.DownstreamRouteFinderMiddleware[0] requestId: 0HMFMPNHV9VHO:00000001, previousRequestId: no previous request id, message: DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /kpiDashboardApi/Report/DocumentTypeCounts, verb: POST. warn: Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId: 0HMFMPNHV9VHO:00000001, previousRequestId: no previous request id, message: Error Code: UnableToFindDownstreamRouteError Message: Failed to match Route configuration for upstream path: /kpiDashboardApi/Report/DocumentTypeCounts, verb: POST. errors found in ResponderMiddleware. Setting error response for request path:/kpiDashboardApi/Report/DocumentTypeCounts, request method: POST

I can't find the missing part . Where is my mistake?

Thanks in advance

Upvotes: 6

Views: 8057

Answers (1)

VoodooSV
VoodooSV

Reputation: 21

I think you mixed Downstream & Upstream up. Try such config (note values for Host and UpstreamPathTemplate):

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/kpiDashboardApi/Report/DocumentTypeCounts",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "https://server_domain.net",
          "Port": 443
        }
      ],
      "UpstreamPathTemplate": "/kpiDashboardApi/Report/DocumentTypeCounts",
      "UpstreamHttpMethod": [ "Post" ]
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:5001"
  }
}

Upvotes: 2

Related Questions