我有一个后端API,说:
GET https://bk.my.com/api/store/goods
,我使用Azure API管理作为代理。这是我的API“我的测试API”的主要设置
Web Service URL: https://bk.my.com/
API URL suffix :
Base URL
https://bk-xxx.azure-api.net
添加API操作,这是操作设置(前端,我仅使用此设置,其他设置保留默认设置)
Display Name: Get all goods
Name : get-all-goods
URL : GET /api/store/goods
有效。自
https://bk-xxx.azure-api.net/api/store/goods => https://bk.my.com/api/store/goods
现在我需要为此API添加一个新版本。这是后端中的v2 API。
GET https://bk.my.com/api/v2/store/goods
我使用标头分类创建了新版本的api名称“ v2”
GET https://bk-xxx.azure-api.net/[operation]
api-version: v2
因此,在“我的测试API”中,有2个版本
>My Test API <operation> <frontend> <inbound>
Original -> get-all-goods -> GET /api/store/goods
v2 -> get-all-goods -> GET /api/store/goods <inbound>
<base />
<rewrite-uri template="/api/v2/store/goods" />
</inbound>
当我测试v2 api却无法正常工作时,跟踪显示:
configuration (0 ms)
{
"message": "Unable to identify Api or Operation for this request. Responding to the caller with 404 Resource Not Found."
}
然后我尝试通过删除rewrite-uri来修复v2 api操作
>My Test API <operation> <frontend> <inbound>
Original -> get-all-goods -> GET /api/store/goods
v2 -> get-all-goods -> GET /api/v2/store/goods
现在可以使用。
所以我的问题是为什么rewrite-uri不起作用?
答案 0 :(得分:0)
我不知道我是否理解您的问题,但是您打算用这个重写-url“”做什么? 您是否要将api请求发送到此网址?我的意思是,这是您的后端网址吗?
如果是,则可以使用set backe-end策略。