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
s1
Helper I
Helper I

Can run GET, but having trouble with POST when sending API from Power Query Online (dataflow)

I am having trouble getting Power Query online to use the search API in Hubspot, and I cannot look at the api request it generates to debug. When I try and do a POST for SEARCH in their API, I get this error:

DataSource.Error: Web.Contents failed to get contents from 'https://api.hubapi.com/crm/v3/objects/tickets/search' (415): Unsupported Media TypeDetailsReason = DataSource.Error
DataSourceKind = Web
DataSourcePath = https://api.hubapi.com/crm/v3/objects/tickets/search
Url = https://api.hubapi.com/crm/v3/objects/tickets/search

 

(I think the only difference between GET and POST in Power Query is whether it has Content = "" or not?)

My only two guesses are either the body json has a formatting error, or Power BI doesn't support POST.

 

This works in Postman:

curl --location 'https://api.hubapi.com/crm/v3/objects/tickets/search' \
--header 'Authorization: Bearer ####' \
--header 'Content-Type: application/json' \
--data '{
    "filterGroups": [
        {
            "filters": [
                {
                    "propertyName": "hs_pipeline_stage",
                    "operator": "EQ",
                    "value": "95185931"
                }
            ]
        }
    ]
}'

 

This works in power BI ( the GET version without search )

let
  Source = Table.FromRecords(Json.Document(Web.Contents(
    "https://api.hubapi.com",
    [
      RelativePath="crm/v3/objects/tickets",
      Headers = [
        Authorization = "Bearer ####",
        #"Conent-Type"="application/json"
        ]
    ]
  ))[results])
in
  Source

 

But this does not work in Power BI (which I think is identical to the postman version?):

let
  filter = Json.FromValue(
    [
      filterGroups = {
        [
          filters = {
            [
              propertyName = "hs_pipeline_stage",
              operator = "EQ",
              value = "95185931"
            ]
          }
        ]
      }
    ]
  ),
  Source = Table.FromRecords(Json.Document(Web.Contents(
    "https://api.hubapi.com",
    [
      RelativePath="crm/v3/objects/tickets/search",
      Headers = [
        Authorization = "Bearer ####",
        #"Conent-Type"="application/json"
        ],
      Content = filter
    ]
  ))[results])
in
  Source

 

1 ACCEPTED SOLUTION
v-rongtiep-msft
Community Support
Community Support

Hi @s1 ,

Please try to modify the codes.

 

powerquery
let
  filter = Json.FromValue(
    [
      filterGroups = {
        [
          filters = {
            [
              propertyName = "hs_pipeline_stage",
              operator = "EQ",
              value = "95185931"
            ]
          ]
        ]
      }
    ]
  ),
  Source = Table.FromRecords(Json.Document(Web.Contents(
    "https://api.hubapi.com",
    [
      RelativePath="crm/v3/objects/tickets/search",
      Headers = [
        Authorization = "Bearer ####",
        #"Content-Type"="application/json"
        ],
      Content = filter
    ]
  ))[results])
in
  Source

 

Web.Contents - PowerQuery M | Microsoft Learn

 

 Please try the above modifications and see if that resolves your issue. If the problem persists, could you provide more details about the error message?

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
s1
Helper I
Helper I

Thank you! Yes, you are right, it was a typo with Content.

v-rongtiep-msft
Community Support
Community Support

Hi @s1 ,

Please try to modify the codes.

 

powerquery
let
  filter = Json.FromValue(
    [
      filterGroups = {
        [
          filters = {
            [
              propertyName = "hs_pipeline_stage",
              operator = "EQ",
              value = "95185931"
            ]
          ]
        ]
      }
    ]
  ),
  Source = Table.FromRecords(Json.Document(Web.Contents(
    "https://api.hubapi.com",
    [
      RelativePath="crm/v3/objects/tickets/search",
      Headers = [
        Authorization = "Bearer ####",
        #"Content-Type"="application/json"
        ],
      Content = filter
    ]
  ))[results])
in
  Source

 

Web.Contents - PowerQuery M | Microsoft Learn

 

 Please try the above modifications and see if that resolves your issue. If the problem persists, could you provide more details about the error message?

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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
Top Kudoed Authors