Skip to content

Instantly share code, notes, and snippets.

@ImkeF
Created January 14, 2019 09:05
Show Gist options
  • Save ImkeF/7202ba50867377988719f2c3492931f7 to your computer and use it in GitHub Desktop.
Save ImkeF/7202ba50867377988719f2c3492931f7 to your computer and use it in GitHub Desktop.
Creates a secret gist with the parameters provided. Optional parameter to make it public.
let func =
(Description as text, FunctionName as text, Content as text, AccessToken as text, optional public as any) =>
let
Public = if public = null then false else true,
GitRecord = [description=Description, public=Public, files=Record.FromTable(#table({"Name", "Value"}, {{FunctionName, [content=Content]}}))],
URL = "https://api.github.com/gists?access_token=" & AccessToken,
BinaryJson = Json.FromValue(GitRecord),
Web= Json.Document(Web.Contents(URL, [#"Headers"=[#"Content-type"="application/json", access_token= AccessToken], Content=BinaryJson]))
in
Web ,
documentation = [
Documentation.Name = " Export.CreateGist.pq ",
Documentation.Description = " Creates a secret gist with the parameters provided. Optional parameter to make it public. ",
Documentation.LongDescription = " Creates a secret gist with the parameters provided. Optional parameter to make it public. ",
Documentation.Category = " Other ",
Documentation.Source = " Imke Feldmann: www.TheBIccountant.com. ",
Documentation.Version = " 1.0 ",
Documentation.Author = " Imke Feldmann: www.TheBIccountant.com. For details see: https://www.thebiccountant.com/2019/01/13/writing-data-to-github-using-power-query-only/ . ",
Documentation.Examples = {[Description = " For details see: https://www.thebiccountant.com/2019/01/13/writing-data-to-github-using-power-query-only/. ",
Code = " ",
Result = " "]}]
in
Value.ReplaceType(func, Value.ReplaceMetadata(Value.Type(func), documentation))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment