Forum Discussion
Yammer Messages
Hi Anonymous,
You need to do some research about yammer rest api. Then you can follow v-shex-msft's suggestion: https://community.powerbi.com/t5/Desktop/How-to-perform-loop-in-M-Query-and-collate-result-of-the-same/td-p/464474.
Also you can reference ImkeF's suggestion here:
let
Pagination = List.Skip(List.Generate( () => [Table = #table({}, {{}}) ,Page = 1, Counter=0], // Start Value
each Table.RowCount([Table])>0 or [Counter]=0, // Condition under which the next execution will happen
each [ WebCall = Json.Document(Web.Contents("https://api.capsulecrm.com/api/v2/parties?perPage=100&page="&Text.From([Page])&"",[Headers=[Authorization="Bearer WAWjGWU6Kbl4o9TeGMRw5i52+kvSiz9xfQe+vNTxlcjw61R7RZYa4HxvdT8TSlDG"]])), // retrieve results per call
Page = [Page]+1,
Counter = [Counter]+1,// internal counter
Table = Table.FromRecords(WebCall[parties]) // steps of your further query
]
,each [Table]
) ,1),
#"Converted to Table" = Table.FromList(Pagination, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandTableColumn(#"Converted to Table", "Column1", {"id", "firstName", "lastName", "createdAt"}, {"id", "firstName", "lastName", "createdAt"}),
#"Removed Duplicates" = Table.Distinct(#"Expanded Column1", {"id"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Duplicates", each [id] <> null)
in
#"Filtered Rows"
Best Regards,
Qiuyun Yu
Thanks qiuyu!. Yammer api is bit more complicated and the paginated query will fetch the duplicated records from pages. However there is a powershell script to get all messages from API using older_than parameter. it would be extremely beneficial if the same logic can be implemented using M in Power BI. Any suggestions or idea would be appreciated.
Yammer Developers API : Get Messages
https://developer.yammer.com/docs/messagesjson
PowerShell Script to get all Yammer Messages:
http://www.nubo.eu/en/blog/2016/12/Get-All-Yammer-Messages-Through-Rest-API-With-PowerShell/
Thanks,
Arjun