我正在对 WuFoo 表单进行 api 调用
要做一个 dateCreated 过滤器,它需要看起来像这样(注意双引号):
Filter1=DateCreated+Is_greater_than+"2019-11-13 12:00:00"
但是,Axios 将其 urlencode 为如下所示:
Filter1=DateCreated%2BIs_greater_than%2B%222019-11-13+12:00:00%22'
不幸的是,WuFoo 对此做出了错误的回应。
我尝试使用 paramSerializer 转义编码:
const instance = axios.create({
baseURL: 'https://subdomain.wufoo.com/api/v3',
timeout: 1000,
headers: { 'Authorization': 'Basic fjdkalfjkdafldklaskflsdkl' },
paramsSerializer: function(params) { return params }
});
……
instance.get('/forms/form/entries.json',{
params:{
Filter1: qDateFilter
}
})
qDateFilter = DateCreated+Is_greater_than+"2019-11-13 12:00:00"
但是我现在有以下错误:
TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
at new ClientRequest (_http_client.js:139:13)
at Object.request (https.js:309:10)
at RedirectableRequest._performRequest (/home/node/app/node_modules/follow-redirects/index.js:169:24)
at new RedirectableRequest (/home/node/app/node_modules/follow-redirects/index.js:66:8)
at Object.wrappedProtocol.request (/home/node/app/node_modules/follow-redirects/index.js:307:14)
at dispatchHttpRequest (/home/node/app/node_modules/axios/lib/adapters/http.js:180:25)
at new Promise (<anonymous>)
at httpAdapter (/home/node/app/node_modules/axios/lib/adapters/http.js:20:10)
at dispatchRequest (/home/node/app/node_modules/axios/lib/core/dispatchRequest.js:59:10)
at processTicksAndRejections (internal/process/task_queues.js:93:5) {
code: 'ERR_UNESCAPED_CHARACTERS'
}
尝试使用直接完整的字符串作为 URL 也不起作用,它仍然对其进行编码。
在邮递员中使用直接 " 效果很好,与 curl 相同。
还有其他选择吗?