Excel 如何使用Power Query发布多部分/表单数据';网站内容

Excel 如何使用Power Query发布多部分/表单数据';网站内容,excel,google-api,google-analytics-api,google-ads-api,powerquery,Excel,Google Api,Google Analytics Api,Google Ads Api,Powerquery,在Power Query中,我可以使用Web.Contents函数从Web下载数据,但有一个api要求请求包含以下格式的多部分/表单数据 “\uu rdxml”= 那么,如何使用Web.Contents函数实现这一点呢 我试过了,正在做 ... PostContent = "__rdxml=<*Some data*>", Source Web.Contents(url,Content=Text.ToBinary(PostContent)) ... 。。。 PostContent=“

在Power Query中,我可以使用Web.Contents函数从Web下载数据,但有一个api要求请求包含以下格式的多部分/表单数据

“\uu rdxml”=

那么,如何使用Web.Contents函数实现这一点呢

我试过了,正在做

...
PostContent = "__rdxml=<*Some data*>",
Source Web.Contents(url,Content=Text.ToBinary(PostContent))
...
。。。
PostContent=“\uu rdxml=”,
源Web.Contents(url,Content=Text.ToBinary(PostContent))
...
但服务器响应为
400错误请求

我用Fiddler检查了原始请求,似乎请求没有使用
content-type=multipart/form-data
头发送

我尝试手动添加
content-type=multipart/form-data
的content-type标题,但也不起作用。响应中相同的
400错误请求


有什么想法吗?

多部分/表单数据是一个相当复杂的编码,需要一堆MIME特定的头。我首先尝试看看您是否可以使用application/x-www-form-urlencoded:

let
    actualUrl = "http://some.url",
    record = [__rdxml="some data"],
    body = Text.ToBinary(Uri.BuildQueryString(record)),
    options = [Headers =[#"Content-type"="application/x-www-form-urlencoded"], Content=body],
    result = Web.Contents(actualUrl, options)
in
    result

编辑:我提出了一个将多部分/表单数据与Power Query结合使用的示例。如果在正文中需要多个值,可以将它们作为逗号分隔的值作为值数组添加到记录中。另外,在下一行中,为了可读性。ie记录=[field1=“一些数据”,field2=“一些数据”]