node.js - How does nodejs call the interface to send a post request?
淡淡烟草味
淡淡烟草味 2017-07-06 10:35:59
0
3
1406

I have used the request-promise module, but the request was not successful. Now I don’t know whether it is a problem with the interface or a problem with my code. Please help me! Thanks!
var rp = require('request-promise');
var form={};
rp({

    method: 'POST',
    uri: 'http://upfiles1.xxx.com/xxx.asmx/Upload',
    //form:form,
    body:form,
    headers: {
        "content-type" : "multipart/form-data",//"application/x-www-form-urlencoded"
        "content-length":form.length
    }
});
提示 Unhandled rejection RequestError: Error: Argument error, options.body.TypeError: first argument must be a string or Buffer
我现在最有疑问的就是我要post过去的数据那里到底是body呢,还是form?

把上面代码中的body改成form又会提示下面的错误,我怀疑是接口的问题,不知道是不是啊?????
Unhandled rejection StatusCodeError: 500 - "System.Web.HttpRequestValidationException: 从客户端(fileData=&quot;...�e���=�T��<yu#5�����d�3L6o�Y�...&quot;)中检测到有潜在危险的 Request.Form 值。
Unhandled rejection StatusCodeError: 500 - "System.InvalidOperationException: 缺少参数: key。\r\n   在 System.Web.Services.Protocols.ValueCollectionParameterReader.Read(NameValueCollection collection)\r\n   在 System.Web.Services.Protocols.HttpServerProtocol.ReadParameters()\r\n   在 System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()\r\n"

48|v3.oa.t | at new StatusCodeError (/mnt/webtest/v3.xx.test.xxx.com/node_modules/.1.1.1@request-promise-core/lib/errors.js:32 :15)
Now it prompts me that the parameter key is missing. My key has been placed in the form. Why is it still missing?

淡淡烟草味
淡淡烟草味

reply all(3)
我想大声告诉你

Upload the code. How do I know what your problem is?

Ty80

uri changed to url? ? ? ?

学霸

From your domain name, it seems that you are uploading files. To upload files, you need to use the FormData object. Please look at this aspect. My mobile phone is not convenient

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!