powerbi api始终返回NotFound

时间:2018-08-08 17:05:22

标签: c# powerbi powerbi-embedded

我正在使用powerbiapi直接拨打powerbi的电话。我已成功通过身份验证,可以成功拨打电话以获取所有数据集

<?xml version="1.0" encoding="utf-8"?>
<ScrollView 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.cancunsteve.aboutcancunsteve.MainActivity"
tools:showIn="@layout/activity_main">


<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    android:layout_alignParentStart="true"
    android:layout_marginTop="56dp" />
<ImageView android:id="@+id/imageView"
    android:layout_column="1"
    android:background="@mipmap/lpussy"
    android:contentDescription='android:ContentDescription="@string/desc"'
    tools:ignore="HardcodedText"
    android:layout_width="200dp"
    android:layout_height="230dp" />


<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="       We&apos;ve been serving good people like you since 1994 with special deals on their     travel plans. "
    android:id="@+id/text1"
    android:layout_alignTop="@+id/imageView"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true"
    android:background="#ffffff"
    android:foreground="#05ffffff"
    android:foregroundTint="#03ffffff"
    android:textColor="#000000" />



<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText2"
    android:text="Cancun, Chichen Itza."
    android:layout_below="@+id/text1"
    android:layout_alignParentRight="true"
    android:layout_alignParentEnd="true" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText"
    android:text="Holbox, Taxco, Palenque, Acapulco, Ixtapa, Guanajuato,  
    Cabo San Lucas, Puerto Vallarta, Monterrey, Tenacatita, Mascota"
    android:layout_below="@+id/editText2"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true" />

    <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/imageButton"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:background="@mipmap/campa"
    tools:ignore="ContentDescription"
    android:layout_alignBottom="@+id/editText5" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="textEmailAddress"
    android:ems="10"
    android:id="@+id/editText3"
    android:text="thewebmaster@cancunsteve.com"
    android:layout_below="@+id/editText"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_alignRight="@+id/editText"
    android:layout_alignEnd="@+id/editText" />

    <EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:inputType="phone"
    android:ems="10"
    android:id="@+id/editText4"
    android:text="       011 52 998 8873919"
    android:layout_below="@+id/editText3"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_marginLeft="42dp"
    android:layout_marginStart="32dp" />

<EditText
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/editText5"
    android:text="be sure to visit us discounts on your hotel bookings"
    android:layout_below="@+id/editText4"
    android:layout_toRightOf="@+id/scrollView"
    android:layout_toEndOf="@+id/scrollView" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="click buttons multiple times to change state"
    android:id="@+id/textView2"
    android:layout_below="@+id/imageButton" />


    </RelativeLayout>
    </ScrollView>

返回我经过身份验证的用户可以访问的所有数据集。

但是当我拨打不同于上面列出的电话的任何其他电话时,会收到var datasets = await _powerBiClient.Datasets.GetDatasetsAsync(_config.GroupId); 异常。

NotFound

var d = await _powerBiClient.Datasets.GetDatasetByIdAsync(_config.GroupId,datasetKey);

var d = await _powerBiClient.Datasets.GetDatasetByIdAsync(datasetKey);

我什至尝试遍历api并通过webrequest直接拨打电话

var r = await _powerBiClient.Datasets.PostRowsAsync(_config.GroupId,getIdResult.Result, tableName,rows);

也引发了string powerBIApiAddRowsUrl = String.Format("https://api.powerbi.com/v1.0/myorg/datasets/{0}/tables/{1}/rows", getIdResult, tableName); //POST web request to add rows. //To add rows to a dataset in a group, use the Groups uri: https://api.powerbi.com/v1.0/myorg/groups/{group_id}/datasets/{dataset_id}/tables/{table_name}/rows //Change request method to "POST" HttpWebRequest request = System.Net.WebRequest.Create(powerBIApiAddRowsUrl) as System.Net.HttpWebRequest; request.KeepAlive = true; request.Method = "POST"; request.ContentLength = 0; request.ContentType = "application/json"; 异常。

看着PowerBi Documentation,我原先将datasetKey作为数据集的名称(即“ DatasetSample”)传递给ID,就像文档中的url示例一样,我仍然得到NotFound

有人可以让我深入了解问题所在吗?

1 个答案:

答案 0 :(得分:0)

NotFound表示您提供的数据集在您提供的组中不存在。 DatasetId和GroupId都应该是GUID。您可以使用GET请求或_powerBIClient获取数据集ID和组ID。

GET /v1.0/myorg/groups

GET /v1.0/myorg/groups/<group id>/datasets

GET /v1.0/myorg/groups/<group id>/datasets/<dataset id>

using powerBIClient:
powerBIClient.Datasets.GetDatasetByIdAsync(groupId, datasetId)

请注意,如果您的数据集位于“我的工作区”中,则API会有所不同。在这种情况下,API为:

GET /v1.0/myorg/datasets

GET /v1.0/myorg/datasets/<dataset Id>

using powerBIClient:
powerBIClient.Datasets.GetDatasetByIdAsync(datasetId)

为进行验证,您始终可以使用powerbi.com中的URL提取组ID和数据集ID。只需尝试从数据集创建报告并查看浏览器URL。

如果以上方法都不适合您,请使用_powerBIClient,打开提琴手并捕获外发请求,然后将其粘贴到此处(当然没有Authorization标头)。