axiosurlencodewufoo

Escape " in axios


I am making an api call to WuFoo forms

to do a dateCreated filter it needs to look like this (note double quote):

Filter1=DateCreated+Is_greater_than+"2019-11-13 12:00:00"

However, Axios urlencodes it to look like this:

Filter1=DateCreated%2BIs_greater_than%2B%222019-11-13+12:00:00%22'

and WuFoo unfortunately returns incorrect response to that.

I have tried escaping the encoding by using 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"

However I now have the following error:

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'
}

Attempts to just use a straight full string as a URL don't work either, it still encodes it.

Using straight " in postman works fine, same with curl.

Any other options?


Solution

  • WuFoo got back to me. It wasn't the " it was actually the encoding of the + sign. I replaced with spaces and it worked.