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="...�e���=�T��<yu#5�����d�3L6o�Y�...")中检测到有潜在危险的 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?
Upload the code. How do I know what your problem is?
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