我正在对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一样。
还有其他选择吗?
答案 0 :(得分:0)
WuFoo回到了我身边。它不是“,它实际上是+符号的编码。我用空格代替,并且可以正常工作。