node-js-libs/curlrequest

Curl request with [brackets] in URL returns error

pixelsage opened this issue · 2 comments

URL to curl request:
https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-ESV

Returns error:
Error: URL malformed. The syntax was not correct.

I think I've narrowed the issue to the URL having brackets, since removing the brackets allows the request to run (though brackets are necessary for a proper response).

API: http://bibles.org/pages/api/documentation/passages
Note: API Key required to run query.

You could try the globoff curl option:

-g, --globoff
This option switches off the "URL globbing parser". When you set this option, you can specify URLs that contain the letters {}[] without having them being interpreted by curl itself. Note that these letters are not normal legal URL contents but they should be encoded according to the URI standard.

curl.request({
  url: 'https://bibles.org/v2/passages.js?q[]=john+3:1-5&version=eng-ESV',
  globoff: true
}, function (err, response) {
  // ...
});

That's the solution! Thanks again for your help.