Web.Contents 方法将内容作为二进制
我使用此代码。有用
query = "{
""field1"" : ""value1"",
""field2"" : ""value2"",
""field3"" : {
""sub_field_3_1"" : [""value_3_1_1"", ""value_3_1_2"", ""value_3_1_1""],
""sub_field_3_2"" : [""value_3_2_1"", ""value_3_2_2"", ""value_3_2_1""]
}
}",
content = Text.ToBinary(query),
Web.Contents("https://my_url", [
Headers = [#"Content-Type"="text/xml; charset=utf-8"],
Content=content
])
我了解,这不是一个好的解决方法,因为没有理由进行双重转换。但我找不到如何应用记录的方法,它应该如下所示:
record = [
field1 = value1,
field2 = value2,
field3 = [
sub_field_3_1 = {value_3_1_1, value_3_1_2, value_3_1_1},
sub_field_3_2 = {value_3_2_1, value_3_2_2, value_3_2_1}
]
],
content = SOME_CONVERTER(record),
Web.Contents("https://my_url", [
Headers = [#"Content-Type"="text/xml; charset=utf-8"],
Content = content
])
尝试使用Uri.BuildQueryString(如何使用 Power Query 的 Web.Contents 发布多部分/表单数据),但它不能正确形成二进制
record = [
field1 = value1,
field2 = value2,
field3 = [
sub_field_3_1 = {value_3_1_1, value_3_1_2, value_3_1_1},
sub_field_3_2 = {value_3_2_1, value_3_2_2, value_3_2_1}
]
],
content = Text.ToBinary(Uri.BuildQueryString(record)),
Web.Contents("https://my_url", [
Headers = [#"Content-Type"="text/xml; charset=utf-8"],
Content=content
]
有更好的解决方法吗?