Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to add -d part of API Request in Get Data from Web.Contents()

Hi All,

I am trying to perform this API Request from the Pendo Documentation

 

curl --location --request POST 'https://app.pendo.io/api/v1/aggregation' \
--header 'X-Pendo-Integration-Key: <PENDO_INTEGRATION_KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "response": {
    "mimeType": "application/json"
  },
  "request": {
    "name": "responseCount",
    "pipeline": [{
      "source": {
        "pollsSeen": {
          "guideId": "{guideId}",
          "pollId": "{pollId}"
        },
        "timeSeries": {
          "period": "dayRange",
          "first": "now()",
          "count": -30
        }
      }
    }, {
      "identified": "visitorId"
    }, {
      "reduce": [{
        "count": {
          "count": "visitorId"
        }
      }]
    }],
    "requestId": "responseCount"
  }
}'

 

 

I am able to get to the guide I want with the following in Power Query, but am unsure how to add the information from "data-raw" to get the list of reponses. Any help is appreciated.

 

 

let
    Source = Json.Document(
        Web.Contents(
            "https://app.pendo.io/api/v1/guide?id=zHMFRgLR-oQgZwdTTmuXzU1qV08",
            [Headers=[#"content-type"="application/json", 
            #"x-pendo-integration-key"="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]
        )
    )
in
    Source

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

-d is for the body content of a POST request. You can add the content to the Content property of Web.Contents() function. Web.Contents - PowerQuery M | Microsoft Learn

  • Content: Specifying this value changes the web request from a GET to a POST, using the value of the option as the content of the POST.

 

You may try 

let
    body = "{
  ""response"": {
  ""mimeType"": ""application/json""
  },
  ""request"": {
    ""name"": ""responseCount"",
    ""pipeline"": [{
      ""source"": {
        ""pollsSeen"": {
          ""guideId"": ""{guideId}"",
          ""pollId"": ""{pollId}""
        },
        ""timeSeries"": {
          ""period"": ""dayRange"",
          ""first"": ""now()"",
          ""count"": -30
        }
      }
    }, {
      ""identified"": ""visitorId""
    }, {
      ""reduce"": [{
        ""count"": {
          ""count"": ""visitorId""
        }
      }]
    }],
    ""requestId"": ""responseCount""
  }
}"",
    Source = Json.Document(
        Web.Contents(
            "https://app.pendo.io/api/v1/guide?id=zHMFRgLR-oQgZwdTTmuXzU1qV08",
            [Content=Text.ToBinary(body), Headers=[#"content-type"="application/json", 
            #"x-pendo-integration-key"="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]
        )
    )
in
    Source

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

1 REPLY 1
v-jingzhang
Community Support
Community Support

Hi @Anonymous 

 

-d is for the body content of a POST request. You can add the content to the Content property of Web.Contents() function. Web.Contents - PowerQuery M | Microsoft Learn

  • Content: Specifying this value changes the web request from a GET to a POST, using the value of the option as the content of the POST.

 

You may try 

let
    body = "{
  ""response"": {
  ""mimeType"": ""application/json""
  },
  ""request"": {
    ""name"": ""responseCount"",
    ""pipeline"": [{
      ""source"": {
        ""pollsSeen"": {
          ""guideId"": ""{guideId}"",
          ""pollId"": ""{pollId}""
        },
        ""timeSeries"": {
          ""period"": ""dayRange"",
          ""first"": ""now()"",
          ""count"": -30
        }
      }
    }, {
      ""identified"": ""visitorId""
    }, {
      ""reduce"": [{
        ""count"": {
          ""count"": ""visitorId""
        }
      }]
    }],
    ""requestId"": ""responseCount""
  }
}"",
    Source = Json.Document(
        Web.Contents(
            "https://app.pendo.io/api/v1/guide?id=zHMFRgLR-oQgZwdTTmuXzU1qV08",
            [Content=Text.ToBinary(body), Headers=[#"content-type"="application/json", 
            #"x-pendo-integration-key"="XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"]]
        )
    )
in
    Source

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors