简体   繁体   中英

POST request from PowerBI - cannot convert a value of type Record to type Number

I am attempting to use an API endpoint as a data source for PowerBI, but I'm encountering some kind of conversion error:

Expression.Error: We cannot convert a value of type Record to type Number.
Details:
    Value=[Record]
    Type=[Type]

Here is the request:

let
   Body  = "{""value"":""org""}",
   Source= Json.Document("https://dev-xxxxx.com:443/ic/api/integration/v1/flows/rest/TEST_4/1.0/test", [Headers =[#"Content-Type"="application/json"], Content = Text.ToBinary(Body)])
in
   Source

This is a sample of the JSON payload that should be returned:

{
  "columns" : [ {
    "name" : "COUNT(*)",
    "type" : ""
  }, {
    "name" : "REGION_NAME",
    "type" : ""
  } ],
  "items" : [ {
    "orgcount()" : 1,
    "region_name" : "California Region"
  } ]
}

I have seen a payload with the same structure come through fine when setting up a connection via the UI, but that was making a GET request, and I need to pass parameters to the endpoint, which is why I'm trying to use Power Query instead.

I've tried using Web.Contents() as in the following:

let
   Body  = "{""value"":""org""}",
   Source= Json.Document(Web.Contents("https://dev-xxxxxx.com:443/ic/api/integration/v1/flows/rest/TEST_4/1.0/test", [Headers =[#"Content-Type"="application/json"], Content = Text.ToBinary(Body)]))
in
   Source

but I get the following error because I'm using basic creds to access the endpoint:

DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
    DataSourceKind=Web
    DataSourcePath=https://dev-xxxxxx.com/ic/api/integration/v1/flows/rest/TEST_4/1.0/test

I am attempting to use an API endpoint as a data source for PowerBI, but I'm encountering some kind of conversion error:

Expression.Error: We cannot convert a value of type Record to type Number.
Details:
    Value=[Record]
    Type=[Type]

Here is the request:

let
   Body  = "{""value"":""org""}",
   Source= Json.Document("https://dev-xxxxx.com:443/ic/api/integration/v1/flows/rest/TEST_4/1.0/test", [Headers =[#"Content-Type"="application/json"], Content = Text.ToBinary(Body)])
in
   Source

This is a sample of the JSON payload that should be returned:

{
  "columns" : [ {
    "name" : "COUNT(*)",
    "type" : ""
  }, {
    "name" : "REGION_NAME",
    "type" : ""
  } ],
  "items" : [ {
    "orgcount()" : 1,
    "region_name" : "California Region"
  } ]
}

I have seen a payload with the same structure come through fine when setting up a connection via the UI, but that was making a GET request, and I need to pass parameters to the endpoint, which is why I'm trying to use Power Query instead.

I've tried using Web.Contents() as in the following:

let
   Body  = "{""value"":""org""}",
   Source= Json.Document(Web.Contents("https://dev-xxxxxx.com:443/ic/api/integration/v1/flows/rest/TEST_4/1.0/test", [Headers =[#"Content-Type"="application/json"], Content = Text.ToBinary(Body)]))
in
   Source

but I get the following error because I'm using basic creds to access the endpoint:

DataSource.Error: Web.Contents with the Content option is only supported when connecting anonymously.
Details:
    DataSourceKind=Web
    DataSourcePath=https://dev-xxxxxx.com/ic/api/integration/v1/flows/rest/TEST_4/1.0/test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM