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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
markvanwyk
Regular Visitor

Oauth2 unsupported media type (415) for Crowdsrtrike

Hi All

 

Please can I ask for assistance - new to PowerBI and Oauth 2 issues to access an API - see below erro and M language query

 

DataSource.Error: Web.Contents failed to get contents from 'https://api.crowdstrike.com/oauth2/token' (415): Unsupported Media Type
Details:
DataSourceKind=Web
DataSourcePath=https://api.crowdstrike.com/oauth2/token
Url=https://api.crowdstrike.com/oauth2/token

 

let
url = "https://api.crowdstrike.com/oauth2/token",

body = "{ ""client_id"": ""xxxxxx"", ""client_secret"": ""xxxxxxxxxx""}",
tokenResponse = Json.Document(Web.Contents(url,[Headers = [#"Content-Type"="application/json"], Content = Text.ToBinary(body) ] )),
AccessToken = tokenResponse[access_token],
AccessTokenHeader = "Bearer " & AccessToken,


data_url = "https://api.crowdstrike.com/devices/queries/devices/v1",
Source = "{
""authorization"": """& AccessTokenHeader & """,
""content-type"": ""application/json""
}",

GetGroups = Json.Document(
Web.Contents(
data_url,
[
Headers = Json.Document(data_body)
]
)
),

#"Converted to Table" = Table.FromRecords({Source}),
#"Expanded meta" = Table.ExpandRecordColumn(#"Converted to Table", "meta", {"query_time", "pagination", "powered_by", "trace_id"}, {"meta.query_time", "meta.pagination", "meta.powered_by", "meta.trace_id"}),
#"Expanded meta.pagination" = Table.ExpandRecordColumn(#"Expanded meta", "meta.pagination", {"offset", "limit", "total"}, {"meta.pagination.offset", "meta.pagination.limit", "meta.pagination.total"}),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded meta.pagination",{{"meta.query_time", type number}, {"meta.pagination.offset", Int64.Type}, {"meta.pagination.limit", Int64.Type}, {"meta.pagination.total", Int64.Type}, {"meta.powered_by", type text}, {"meta.trace_id", type text}, {"resources", type any}, {"errors", type any}})
in
#"Changed Type"

 

 

Thanks Mark

 

1 ACCEPTED SOLUTION
wardy912
Super User
Super User

Hi @markvanwyk 

 

(415): Unsupported Media Type - means the API doesn't like the format of the data you're sending. Specifically, CrowdStrike's OAuth2 token endpoint expects the data to be sent as application/x-www-form-urlencoded, not as JSON. Try this:

 

let
    url = "https://api.crowdstrike.com/oauth2/token",
    body = "client_id=xxxxxx&client_secret=xxxxxxxxxx",
    tokenResponse = Json.Document(
        Web.Contents(
            url,
            [
                Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
                Content = Text.ToBinary(body)
            ]
        )
    ),
    AccessToken = tokenResponse[access_token],
    AccessTokenHeader = "Bearer " & AccessToken,

    data_url = "https://api.crowdstrike.com/devices/queries/devices/v1",
    GetGroups = Json.Document(
        Web.Contents(
            data_url,
            [
                Headers = [
                    #"Authorization" = AccessTokenHeader,
                    #"Content-Type" = "application/json"
                ]
            ]
        )
    )
in
    GetGroups

 Fixes applied

Changed Content-Type to application/x-www-form-urlencoded for the token request.
Changed the body format to URL-encoded string: client_id=...&client_secret=...
Removed unnecessary JSON formatting for headers.

 

Please giver a thumbs up and mark as solved if this helps, thanks!

View solution in original post

4 REPLIES 4
markvanwyk
Regular Visitor

Thanks a mill - working well

v-nmadadi-msft
Community Support
Community Support

Hi @markvanwyk ,
Thanks for reaching out to the Microsoft fabric community forum.


The 415 unsupported media type error is often a result of simple misconfiguration in header or payload structure. Please ensure that your Content-type is correct and your header is without any issue.
Small changes can lead to significant API interaction improvements.

I hope this information helps. Please do let us know if you have any further queries.
Thank you

Omid_Motamedise
Super User
Super User

This is coming from the OAuth2 token request, and it means that the server is rejecting the request because the content type or format of the request body is incorrect. The CrowdStrike API expects the token request to be sent as application/x-www-form-urlencoded, not JSON. So use the following code.

let
    url = "https://api.crowdstrike.com/oauth2/token",
    body = "client_id=xxxxxx&client_secret=xxxxxxxxxx&grant_type=client_credentials",
    tokenResponse = Json.Document(Web.Contents(url, [
        Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
        Content = Text.ToBinary(body)
    ])),
    AccessToken = tokenResponse[access_token],
    AccessTokenHeader = "Bearer " & AccessToken,
    data_url = "https://api.crowdstrike.com/devices/queries/devices/v1",
    GetGroups = Json.Document(Web.Contents(data_url, [
        Headers = [
            #"Authorization" = AccessTokenHeader,
            #"Content-Type" = "application/json"
        ]
    ])),
    #"Converted to Table" = Table.FromRecords({GetGroups})
in
    #"Converted to Table"

 

 

 

 

 


If my answer helped solve your issue, please consider marking it as the accepted solution.
wardy912
Super User
Super User

Hi @markvanwyk 

 

(415): Unsupported Media Type - means the API doesn't like the format of the data you're sending. Specifically, CrowdStrike's OAuth2 token endpoint expects the data to be sent as application/x-www-form-urlencoded, not as JSON. Try this:

 

let
    url = "https://api.crowdstrike.com/oauth2/token",
    body = "client_id=xxxxxx&client_secret=xxxxxxxxxx",
    tokenResponse = Json.Document(
        Web.Contents(
            url,
            [
                Headers = [#"Content-Type" = "application/x-www-form-urlencoded"],
                Content = Text.ToBinary(body)
            ]
        )
    ),
    AccessToken = tokenResponse[access_token],
    AccessTokenHeader = "Bearer " & AccessToken,

    data_url = "https://api.crowdstrike.com/devices/queries/devices/v1",
    GetGroups = Json.Document(
        Web.Contents(
            data_url,
            [
                Headers = [
                    #"Authorization" = AccessTokenHeader,
                    #"Content-Type" = "application/json"
                ]
            ]
        )
    )
in
    GetGroups

 Fixes applied

Changed Content-Type to application/x-www-form-urlencoded for the token request.
Changed the body format to URL-encoded string: client_id=...&client_secret=...
Removed unnecessary JSON formatting for headers.

 

Please giver a thumbs up and mark as solved if this helps, thanks!

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.