-
Notifications
You must be signed in to change notification settings - Fork 0
/
TestTypes.pq
25 lines (20 loc) · 1.14 KB
/
TestTypes.pq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
let
// first call to get access token
// enter your integration key here
SecretKey = "YOUR_INTEGRATION_KEY",
// makes call to get access token
Source = Json.Document(Web.Contents(" https://cloud.hawkindynamics.com/api/token", [Headers=[Authorization="Bearer " & SecretKey]])),
ResponseTable = Table.FromRecords({Source}),
NewTable = Table.TransformColumnTypes(ResponseTable,{{"access_token", type text}, {"token_type", type text}, {"expires_at", Int64.Type}}),
// extract access token from response table
tokenList = NewTable[access_token],
accessToken = Text.From(tokenList{0}),
// second call for group data
Source2 = Json.Document(Web.Contents("https://cloud.hawkindynamics.com/api/dev/test_types", [Headers=[Authorization="Bearer " & accessToken]])),
// Convert JSON list of records to table
RecordList = Source2,
ConvertedTable = Table.FromList(RecordList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
// Expand the records into columns
ExpandedTable = Table.ExpandRecordColumn(ConvertedTable, "Column1", Record.FieldNames(RecordList{0}))
in
ExpandedTable