データ エクスプローラー - Power BI

こんにちは。

API経由でData ExplorerからPBIにデータを呼び出すために、以下のコードを使用しています。

(queryID) => let
        resultCount = 10000,
        otherNameForPage = 0,

        GetPage = (otherNameForPage) =>
            let
                content1 = "params={" & "\"page\"" & ":" & Number.ToText(otherNameForPage) & "}",
                RawData = Json.Document(Web.Contents(
                    "https://forum.xxxxxx.com/admin/plugins/explorer/queries",
                    [RelativePath=Number.ToText(queryID) & "/run",
                        Query=[
                            params="{" & "\"page\"" & ":" & Number.ToText(otherNameForPage) & "}"
                        ],

                        Headers=[
                        #"api-username"="xxxxxxxx",
                        #"api-key"="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
                        #"Content-Type" = "application/x-www-form-urlencoded"],
                        Content=Text.ToBinary(content1)
                    ]

                ) ),
                resultCount = RawData[result_count]
            in
                if RawData[result_count] = 0 then null else RawData,
            Pages = List.Generate(
                () => [i = 0, RawData = GetPage(i)],
                each [RawData] <> null,
                each [i=[i]+1, RawData = GetPage(i)],
                each Table.Combine(let raw = [RawData] in List.Transform(raw[rows], each Table.FromRows({_}, raw[columns])))),
            Output = Table.Combine(Pages)
in
    Output

このコードで以下のクエリからデータをロードできました。

--[params]
-- integer :page = 0

select users.id, users.username, user_custom_fields.value from users, user_custom_fields
where users.id = user_custom_fields.user_id and user_custom_fields.name ='user_field_1'

OFFSET :page * 10000
LIMIT 10000

しかし、以下のクエリを含む別のレポートを呼び出すと、422 : Unprocessable Entity が返されます(エラーが返されるまでに時間がかかります)。

SELECT
  user_id,
  COUNT(*) AS visits
FROM user_visits
WHERE visited_at > CURRENT_DATE - 30
GROUP BY 1
ORDER BY 2 DESC

修正は可能でしょうか?

そのクエリはData Explorer UIで実行されますか?もしそこで動作するのに、PowerBI連携で動作しないのであれば、問題はDiscourse以外の場所にあります。

「いいね!」 1

@Falco、その通りです。レポートはData Explorer UIで即座に機能します

エラーの原因を調べていたところ、この説明を見つけました。
The HyperText Transfer Protocol (HTTP) **422 Unprocessable Entity** response status code indicates that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions.
これはサーバーから来ているようですね?