How to POST a multipart/form-data using Power Query's Web.Contents

后端 未结 1 723
抹茶落季
抹茶落季 2021-01-14 10:42

In Power Query, I can download data from Web using the Web.Contents function, but there\'s an api that required the request to contains multipart/form data in the following

相关标签:
1条回答
  • 2021-01-14 11:09

    multipart/form-data is a fairly complicated encoding, requiring a bunch of MIME-specific headers. I would first try to see if you can use application/x-www-form-urlencoded instead:

    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
    

    EDIT: I've come up with an example of using multipart/form-data with Power Query. It's at https://gist.github.com/CurtHagenlocher/b21ce9cddf54e3807317

    0 讨论(0)
提交回复
热议问题