邮递员无法处理 url 中的 unicode 字符以进行路由

postman could not handle unicode characters in url for routing

我在 WSO2 ESB 中定义了一个 API 资源 GET方法:

/sms/{username}/{password}/{src}/{destination}/{body}

现在,如果我通过 chrome 或 firefox 等标准浏览器调用我的 API,它工作正常,我得到响应代码 ok 200

127.x.x.x:8280/sms/username/password/123123123/456456456/سلام

但我无法通过 Postman 调用此 API 并且它 returns Not-Found 404。如果我将 'سلام' 替换为标准 ascii 字符串,如 'hello' 它工作正常它 returns 代码 ok 200:

127.x.x.x:8280/sms/username/password/123123123/456456456/hello

我在 postmanHeaders 选项卡中尝试了很多 Content-Types 包括这个但是它没有用:

text/html; charset=UTF-8

我还使用 fiddler 监控网络请求。使用此参数的标准浏览器发送请求:

Connection: keep-alive Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,/;q=0.8 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.9

Postman 发送带有此参数的请求:

Content-Type: text/html; charset=UTF-8 cache-control: no-cache Postman-Token: 5ccc574f-54d2-4c5b-ac72-b0f5f5a8e0be User-Agent: PostmanRuntime/7.3.0 Accept: / accept-encoding: gzip, deflate Connection: keep-alive

我用的是postmanv6.4.4

我用 WSO2 ESB 5.0.0 试过这个问题。正如您通过 postman 所期望的那样,它对我有用。

<api xmlns="http://ws.apache.org/ns/synapse" name="test-api" context="/test">
   <resource methods="GET" uri-template="/value/{val1}">
      <inSequence>
         <log level="full">
            <property name="test" expression="get-property('uri.var.val1')"/>
         </log>
         <payloadFactory media-type="json">
            <format>{ "test": ""}</format>
            <args>
               <arg evaluator="xml" expression="get-property('uri.var.val1')"/>
            </args>
         </payloadFactory>
         <respond/>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </resource>
</api>

请求:http://localhost:8280/test/value/سلام

回复:

{
    "test": "سلام"
}

尝试使用 WSO2 ESB 5.0.0。

您需要手动编码 URL 的部分内容。

试试这个