I'm trying to duplicate an Insomnia POST request to an API endpoint in Excel. I believe I'm close but I'm obviously missing something in the Excel Power Query request.
Here is the working CURL request from Insomnia:
curl --request POST \
--url https://url.... \
--header 'Authorization: Bearer <<TOKEN VALUE>>' \
--header 'Content-Type: application/json' \
--data '{ "start":"2023-11-29", "end":"2023-11-29" }
And here is the Power Query request. Note that I'm pulling value for the data and token from named ranges in the workbook.
let
Token = Excel.CurrentWorkbook(){[Name="Token"]}[Content]{0}[Column1],
FromDate = Excel.CurrentWorkbook(){[Name="FromDate"]}[Content]{0}[Column1],
ToDate = Excel.CurrentWorkbook(){[Name="ToDate"]}[Content]{0}[Column1],
headers = [#"Authorization"="Bearer "&Token,#"Content-Type"="application/json"],
postData = Json.FromValue([start = FromDate, end = ToDate]),
Source = Json.Document(Web.Contents("https://url...", [Headers=headers, Content=postData]))
in
Source