我需要将3个表单数据字段和文本文件发布到api端点。我正在使用msxml2.serverXMLhttp.6.0,我有几个API调用正常工作。但是需要上传文本文件的那个。
我正在创建多部分有效负载,但我不确定如何上传文件。 API文档位于http://developer.act-on.com/documentation/list-api/endpoint-update-merge-list/
我认为它不是API特定的,而是使用msxml2.serverXMLhttp.6.0和multipart / form-data
获取文本文件和一些表单字段的简单问题我知道我错过了一些东西,这可能是显而易见的......只是不对我而言
strRequestStart = "--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""listname""" & vbCrlf & vbCrlf & _
"rob666" & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""foldername""" & vbCrlf & vbCrlf & _
"" & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""headings""" & vbCrlf & vbCrlf & _
"N" & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""fieldseparator""" & vbCrlf & vbCrlf & _
"COMMA" & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""quotecharacter""" & vbCrlf & vbCrlf & _
"DOUBLE_QUOTE" & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""uploadspecs""" & vbCrlf & vbCrlf & _
Server.URLEncode(uploadspecs) & vbCrlf & vbCrlf & _
"--" & strBoundary & vbCrlf & _
"Content-Disposition: form-data; name=""file""; filename=""" & strFilename & """" & vbCrlf & _
"Content-Type: text/comma-separated-values" & vbCrlf & _
"--" & strBoundary & "--" & vbCrlf
set HTTP=server.CreateObject("Msxml2.ServerXMLHTTP.6.0")
HTTP.Open "POST", ("https://restapi.actonsoftware.com/api/1/list"), False
HTTP.setRequestHeader "Content-Type","multipart/form-data; boundary=--" & sBoundary
HTTP.setRequestHeader "Authorization", "Bearer " & access_token
HTTP.send(strRequestStart)
文本文件与asp页面位于同一目录中,权限正确。 我已正确配置边界线段并在末尾关闭边界
是否需要内容长度?