request: Error: Invalid URI "/"
I find this package to be really pedantic about options. can someone point out what might be the error in the below?
error [Error: Invalid URI "/"]
options {
uri: 'https://tracker.dashbot.io/track',
json: true,
qs:
{ platform: 'generic',
v: '0.6.0',
apiKey: 'xxxxx',
type: 'outgoing' },
method: 'POST',
href: '',
pathname: '/'
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 8
- Comments: 19
I ran into this issue as well. I was able to resolve it by consolidating all of the options I was trying to set into one object.
What didn’t work
What did
or
The form data is considered an option, so it should live in the options object. It looks like the function still takes a string parameter as the first argument for the URI, but you can omit that and add it to your options object instead if you’d prefer — both ways worked for me. Just be sure you’re passing only one options object in.
I hope this helps anyone else who finds themselves here.
keep. either docs or code should change based on notes above.
@maxgardner thanks for the info! This ticket keeps pinging me with ‘me toos’ for the last couple of years…
The solution from @maxgardner worked like a charm.
If you’re using brackets to put your url, don’t close it and open another after it just to put your header options, form data or stuff, those must all be inside the first brackets.
I moved everything together and it worked.
(Snippet from @maxgardner)
This issue can be closed.
I got a response
{ success: true }using the exact options you specified. I’m not sure what your error is caused by, but it does not seem to be related to request. Tested with request 2.74.0 and Node.js 4.4.7 LTSHere’s my test code for reference