我试图弄清楚如何使用此节点模块实际发布数据:
https://github.com/SamDecrock/node-http-ntlm

看起来发布应该类似于:
https://github.com/SamDecrock/node-httpreq#post

但是httpreq的文档实际上没有显示POST值,我只看到参数或如何POST整个文件。我正在使用节点,并遵循以下原则:

NodeClient.prototype.create = function (xml) {

var options = {
    url: this.url,
    username: this.user,
    password: this.pw,
    domain: this.domain,
    headers: {
        'Content-type': 'text/plain'
    }
};

    return new Promise(function (resolve, reject) {
        httpntlm.post(options,
        function (err, resp) {
            if(err) {
                reject(err);
            }
            resolve(resp.body);
        });
   });
};


显然,我从未发送过xml对象,因此我需要弄清楚如何包括它。阅读文档并没有带我到这一步。

最佳答案

要将内容添加到帖子中,您可以包括以下选项:


json:如果您想直接发送json(内容类型设置为application / json)
files:要上传文件的对象(内容类型设置为multipart / form-data; boundary = xxx)
正文:您要发送的自定义正文内容。如果使用,以前的选项将被忽略,您的自定义主体将被发送。 (不会设置内容类型)

关于node.js - 如何使用node-http-ntlm发布数据?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33153979/

10-16 21:22