2016-03-25 29 views
2

JSONを生成するWebサービスがあります。 jQuery RESTの呼び出しを行い、データを表にバインドします。Power Bi Webサービスへのクエリ - エラー:Expression.Error:値をレコードに変換できません

サービスは、このようなコードとC#のWEBAPIです:

"[{\"School\":\"UM \",\"Students\":\"500\"},{\"School\":\"FIU \",\"Students\":\"700\"},{\"School\":\"UF \",\"Students\":\"600\"},{\"School\":\"GT \",\"Students\":\"300\"}]" 

我々は正常にこのようなサービスを消費jQueryのRESTを持っている:

data = serializer.Serialize(rows); 
    return Request.CreateResponse(HttpStatusCode.OK, lstFilteredData, Configuration.Formatters.JsonFormatter); 

それはこのようにすることをJSONを生成します

$.ajax({ 
     url: 'https://myservices')), 
     type: 'GET', 
     dataType: 'json', 
     cache: false, 
     crossDomain: true, 
     //async: false, 
     success: function (data){ onQuerySucceededWeb(data,true,param);} 
    }); 

私はPower Biを使用してそのデータについて報告するつもりです。マイPowerBiクエリスクリプトです: 私はこのエラーを取得してい

Source = Json.Document(Web.Contents("https://mywebservices")), 
    #"Converted to Table" = Record.ToTable(Source), 
    #"Expanded Value" = Table.ExpandListColumn(#"Converted to Table", "Value"), 
    #"Expanded Value1" = Table.ExpandRecordColumn(#"Expanded Value", "Value", {"School", "Students"}, {"Value.School", "Value.Students"}) 

in 
    #"Expanded Value1" 

を聞かせて:返されるJSONが文字列であるため、

**Expression.Error: We cannot convert the value "[{"School":"UM  ..." to type Record.** 
Details: 
    Value=[{"School":"UM  ","Students":"500"},{"School":"FIU  ","Students":"700"},{"School":"UF  ","Students":"600"},{"School":"GT  ","Students":"300"}] 
    Type=Type 

enter image description here

+0

? –

+0

どこに置くの?私のクエリスクリプト全体の代わりに? – o365spo

+0

と同じです。 Expression.Error: "[{\\ School \":\ "UM ..."の値をレコードに変換することはできません。 – o365spo

答えて

0

JSONがオブジェクトのJSON文字列であるため、サーバーで何かが壊れている可能性があります。サーバはJSONテキストを文字列化していなかった場合、あなたのMクエリは、文字通りこれらのバイトを生産し、つまり働いているだろう:

[{"School":"UM ","Students":"500"},{"School":"FIU ","Students":"700"},{"School":"UF ","Students":"600"},{"School":"GT ","Students":"300"}] 

あなたは自分のMが再び動作するように取得したい場合は、JSONをダブルデコードすることができます。 :あなたは = Text.FromBinary()Web.Contents( "// mywebservices HTTPS")を使用した場合に現れる何

= Json.Document(Json.Document(Web.Contents("https://mywebservices"))) 
+0

ええ、私たちはサービスで二重エンコードされていました。 – o365spo

0

Json.Documentは、テキスト値を返します。引用符を削除すると、Json.Documentはそれをオブジェクトのリストとして解析する必要があります。これはうまくいくはずです:

let 
    Source = Web.Contents("https://mywebservices") 
    Custom1 = Text.Range(Source, 1, Text.Length(Source) - 2), 
    Custom2 = Json.Document(Custom1), 
    #"Converted to Table" = Table.FromList(Custom2, Splitter.SplitByNothing(), null, null, ExtraValues.Error), 
    #"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"School", "Students"}, {"School", "Students"}) 
in 
    #"Expanded Column1"` 

これは、Webサイトが空の文字列を返すと失敗します。

+0

次の行:= Table.ExpandRecordColumn(# "表に変換"、 "Column1"、{"学校"、 "学生"}、{"学校"、 "学生"})このエラーが発生しました:Expression.Error :バイナリタイプの値をテキストタイプに変換することはできません。 詳細: 値=バイナリ タイプ=タイプ – o365spo

+0

ブラウザのサービスから返される内容の実際のスクリーンショットを参照してください。 – o365spo

+0

エラーは実際にこの行にあります:= Text.Range(Source、1、Text.Length(Source)-2) – o365spo

関連する問題