Skip to content

Instantly share code, notes, and snippets.

@saostad
Forked from petrsvihlik/GitHub-GraphQL-PowerBI.m
Created August 13, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saostad/5e725481fdf23404717c97d40a44a5c7 to your computer and use it in GitHub Desktop.
Save saostad/5e725481fdf23404717c97d40a44a5c7 to your computer and use it in GitHub Desktop.
Loading GraphQL data (GitHub API v4) into PowerBI
// This script shows how to use M language (Power Query Formula Language)
// to read data from GitHub API v4 using a POST request.
// This can come in handy when building PowerBI reports that utilize GraphQL endpoints for loading data.
let
Source = Web.Contents(
"https://api.github.com/graphql",
[
Headers=[
#"Method"="POST",
#"Content-Type"="application/json",
#"Authorization"="Bearer <your_personal_token_here>"
],
// Notice the quote escaping here
Content=Text.ToBinary("{""query"": ""{ organization(login: \""github\"") { name }}""}")
]
),
#"JSON" = Json.Document(Source)
in
#"JSON"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment