Node.JS Request - Invalid URI "/"

I use request in my application to send a POST request via HTTPS with client authentication. The request always throws an Error: Invalid URI "/" error, and I could not do anything to solve it. I tried using url.parse instead of passing a string, but it's still the same.

 request.post({ uri: 'https://localhost:5000', key: credentials.key, ca: credentials.ca, cert: credentials.cert, passphrase: credentials.passphrase, rejectUnauthorized: false }, { form: { data: payload }}); 
+7
requestjs
source share
1 answer

It turns out that this was caused by passing the second object to request.post , it should be inside the first object.

 request.post('https://localhost:5000/', { key: credentials.key, ca: credentials.ca, cert: credentials.cert, passphrase: credentials.passphrase, rejectUnauthorized: false, form: { data: payload } }); 
+8
source share

All Articles