Typecast non-derived types - Smart API Connector for Power BI - - Help - Hexagon PPM

Smart API Connector for Power BI Help

PPMProduct
Smart API Connector for Power BI
PPMCategory_custom
Help

The sample Smart API shown in this section supports a non-derived entity scheme, based on the Org.OData.Core.V1.MayImplement annotation. The following $metadata shows that instances of Com.Ingr.SampleApi.V1.Pipe may be cast to Com.Ingr.SampleApi.V1.CatalogItem and in reverse.

<Annotations Target="Com.Ingr.SampleApi.V1.Pipe">

...

<Annotation Term="Org.OData.Core.V1.MayImplement">

<Collection>

<String>Com.Ingr.SampleApi.V1.CatalogItem</String>

</Collection>

</Annotation>

</Annotations>

<Annotations Target="Com.Ingr.SampleApi.V1.CatalogItem">

...

<Annotation Term="Org.OData.Core.V1.MayImplement">

<Collection>

<String>Com.Ingr.SampleApi.V1.Pipe</String>

</Collection>

</Annotation>

</Annotations>

Typically, a client appends a type-cast URL segment to limit response data (based on a derived type). For example, to limit a query for PlantItems to Pipes:

GET https://<server>/api/v1/Sites(‘Id’)/Plants(‘Id’)/Pipes/Com.Ingr.SampleApi.V1.CatalogItem/

The approach is identical to that shown above in Typecast derived types.

The following steps provide an overview:

  1. After you connect to a Smart API, the Navigator dialog box shows all available OData entity sets.

  2. Select an entity set that supports casting to a non-derived type and click Transform Data to load the Power Query Editor.

    Certain Smart APIs use the multi-tenant pattern that exposes a single entity set at the service root, for example, Sites. In this case, you must navigate to the desired entity set after selecting and loading the single entity set.

    You must be familiar with the MayImplement annotations for entities in the Smart API. See the specific Smart API annotations/$metadata document or API documentation for details.

    In this example, the Sites/Plants/Pipes entity set is used.

  3. Click the View tab, and then Advanced Editor. The editor displays something similar to the following:

    The query for the Sites/Plants/Pipes navigation property collection stores the result in #"E63F816D-B7E7-4FC9-AE62-7E709AFF290E".

  4. Modify the code in the Advanced Editor to typecast that result to catalog items using the SmartApiOData.Typecast function.

  5. Click Done. The table updates to display CatalogItems data.