ovh / node-ovh

Node.js wrapper for the OVH APIs
http://ovh.github.io/node-ovh
Other
133 stars 27 forks source link

ERR_UNESCAPED_CHARACTERS #40

Closed xontik closed 2 years ago

xontik commented 4 years ago

I got this kind of error :

ovh_dns    | TypeError [ERR_UNESCAPED_CHARACTERS]: Request path contains unescaped characters
ovh_dns    |     at new ClientRequest (_http_client.js:151:13)
ovh_dns    |     at Object.request (https.js:310:10)
ovh_dns    |     at Ovh.request (/app/node_modules/ovh/lib/ovh.es5.js:380:23)
ovh_dns    |     at /app/node_modules/ovh/lib/ovh.es5.js:457:23
ovh_dns    |     at Promise._execute (/app/node_modules/bluebird/js/release/debuggability.js:384:9)
ovh_dns    |     at Promise._resolveFromExecutor (/app/node_modules/bluebird/js/release/promise.js:518:18)
ovh_dns    |     at new Promise (/app/node_modules/bluebird/js/release/promise.js:103:10)
ovh_dns    |     at Ovh.requestPromised (/app/node_modules/ovh/lib/ovh.es5.js:456:14)
ovh_dns    |     at Task.execution (/app/src/index.js:43:31) {
ovh_dns    |   code: 'ERR_UNESCAPED_CHARACTERS'
ovh_dns    | }

My code is pretty simple :

try {
    const [record, ip] = await Promise.all([getRecord(zone, params), publicIp.v4()]);

    if (record.target === ip) {
      console.log('Already good ip, do nothing')
      return
    }

    console.log(`Changing ip from ${record.target} to ${ip}`);

    const putRequest = await ovh.requestPromised('PUT', `/domain/zone/${zone}/record/${record.id}`, {
      target: ip
    });

    const refresh = await ovh.requestPromised('POST', ` /domain/zone/${zone}/refresh`);

} catch (e) {   
  console.error(e)
}

Task.execution (/app/src/index.js:43:31 indicate that it's the line :

const refresh = await ovh.requestPromised('POST', /domain/zone/${zone}/refresh);

rbeuque74 commented 4 years ago

Hello, In the line you mentioned:

    const refresh = await ovh.requestPromised('POST', ` /domain/zone/${zone}/refresh`);

there is an extra space before the beginning of the URL. Just remove it and it should works ;)

xontik commented 4 years ago

Argh ! Nice catch ... I'll check that soon and come back to close if it works ;)