本文介绍了Power Query,使用表单数据发出http POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个REST API,该API仅接受带有表单数据的POST请求.
I have a REST API, which accepts only POST requests with form data.
我知道在Power Query中,JSON请求是这样的:
I know that in Power Query JSON requests are like this:
let url = "example", body = "{ ""first_param"": ""AAAAA"", ""second_param"": ""BBBBBB""}", Source = Json.Document(Web.Contents(url,[ Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )) in Source如何发送表格数据?
推荐答案使用Uri.BuildQueryString和Json.Document
let url = "example", body = "{ ""first_param"": ""AAAAA"", ""second_param"": ""BBBBBB""}", Parsed_JSON = Json.Document(body), BuildQueryString = Uri.BuildQueryString(Parsed_JSON), Source = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(BuildQueryString) ] )) in Source顺便说一句,您最好将 body 直接构造为 record ,避免使用文本字符串和双引号的双引号)
btw, you'd better construct body directly into a record, avoiding text string and double of double quotes )
更多推荐
Power Query,使用表单数据发出http POST请求
发布评论