简体   繁体   中英

Node.JS Request - Invalid URI “/”

I'm using request in my app to send a POST request over HTTPS with Client Authentication. Request always throws an error Error: Invalid URI "/" and I couldn't do anything to solve it. I've tried used 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 }});

Turns out it 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 }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM