Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

Power BI Fabric - Create semantic model with via Microsoft Fabric API

Hi Everyone,

 

I’m currently exploring the Microsoft Fabric API, specifically the Items - Create Semantic Model REST API (SemanticModel) as detailed on Microsoft Learn. Items - Create Semantic Model - REST API (SemanticModel) | Microsoft Learn

 

I am facing error 400 - 

{"requestId":"b2bfe832-a486-4bd2-ac00-c271415768ac","errorCode":"InvalidDefinitionParts","moreDetails":[{"errorCode":"InvalidPlatformFile","message":"Invalid platform file"}],"message":"One or more definition parts missing or invalid"}

 

I am using structure for request boby content: 

modelBim:

string modelBimContent = @"{""name"": ""SalesModel"",""model"": {""tables"": [{
""name"": ""Sales"",""columns"": [{""name"": ""SalesID"", ""dataType"": ""int""},{""name"": ""Amount"", ""dataType"": ""decimal""}]}]}}";

definitionPbism:
string definitionPbismContent = @"{""version"": ""1.0"",""connections"": [{""connectionType"": ""PowerBI"",""connectionString"": ""Server=myserver;Database=mydb;""}]}";

.platform:

string platformContent = @"{""version"": ""1.0"",""platform"": ""PowerBI"",""settings"": {""storageMode"": ""InMemory"",""queryMode"": ""DirectQuery""}}";

 

My questions are:

1. How can I create a semantic model Fabric API?

2.How to resolve the error.

3. Please help to provide sample request body content in Semantic model create.

4. Any another way for creating the semantic model uisng fabric API 

 

Any help would be greatly appreciated!

 

 

  • The error "Invalid platform file" indicates an issue with the .platform part you supplied. How did you get this file? Did you construct is manually? There's a schema for this file, and what you've sent probably doesn't conform to that schema.

    You can try creating without this part if you don't know how to construct it.

8 Replies

  • AmosHersch's avatar
    AmosHersch
    Icon for Microsoft Employee rankMicrosoft Employee

    The error "Invalid platform file" indicates an issue with the .platform part you supplied. How did you get this file? Did you construct is manually? There's a schema for this file, and what you've sent probably doesn't conform to that schema.

    You can try creating without this part if you don't know how to construct it.

  • Here's a tiny one I used for testing.  I created one in PBI first and exported to pbip.  

    {
        "name": "UploadedSMTest",
        "compatibilityLevel": 1550,
        "model": {
            "culture": "en-US",
            "dataAccessOptions": {
                "legacyRedirects": true,
                "returnErrorValuesAsNull": true
            },
            "defaultPowerBIDataSourceVersion": "powerBI_V3",
            "sourceQueryCulture": "en-US",
            "tables": [{
                    "name": "Applications",
                    "lineageTag": "c549ffef-c9e8-4320-a6c7-1ad879c6f368",
                    "columns": [{
                            "name": "Id",
                            "dataType": "string",
                            "isNullable": false,
                            "sourceColumn": "Id",
                            "sourceProviderType": "uniqueidentifier",
                            "lineageTag": "26c50fc8-c33e-4719-8a9e-bc82ba1cfb48",
                            "summarizeBy": "none",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }, {
                            "name": "Name",
                            "dataType": "string",
                            "isNullable": false,
                            "sourceColumn": "Name",
                            "sourceProviderType": "nvarchar(450)",
                            "lineageTag": "eb2102dc-9c35-4bdd-a577-86ca938c63c2",
                            "summarizeBy": "none",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }, {
                            "name": "Ordinal",
                            "dataType": "int64",
                            "isNullable": false,
                            "sourceColumn": "Ordinal",
                            "formatString": "0",
                            "sourceProviderType": "int",
                            "lineageTag": "0a30dc9f-2112-44ca-87f7-229acfd33254",
                            "summarizeBy": "sum",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }, {
                            "name": "Logo",
                            "dataType": "string",
                            "sourceColumn": "Logo",
                            "sourceProviderType": "nvarchar(max)",
                            "lineageTag": "5ba19601-51ab-44c8-9446-82f31187ddfe",
                            "summarizeBy": "none",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }, {
                            "name": "FileName",
                            "dataType": "string",
                            "sourceColumn": "FileName",
                            "sourceProviderType": "nvarchar(max)",
                            "lineageTag": "3d6b9fc3-163a-4760-8ea5-08c737fd7d7d",
                            "summarizeBy": "none",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }, {
                            "name": "IsActive",
                            "dataType": "boolean",
                            "isNullable": false,
                            "sourceColumn": "IsActive",
                            "formatString": "\"TRUE\";\"TRUE\";\"FALSE\"",
                            "sourceProviderType": "bit",
                            "lineageTag": "33149fb3-d533-4eff-8bad-911b5ab6a54b",
                            "summarizeBy": "none",
                            "annotations": [{
                                    "name": "SummarizationSetBy",
                                    "value": "Automatic"
                                }
                            ]
                        }
                    ],
                    "partitions": [{
                            "name": "Applications",
                            "mode": "directQuery",
                            "source": {
                                "type": "m",
                                "expression": [
                                    "let",
                                    "    Source = Sql.Database(\"xxxx-sql.database.windows.net\", \"yyyy\"),",
                                    "    dbo_Applications = Source{[Schema=\"dbo\",Item=\"Applications\"]}[Data]",
                                    "in",
                                    "    dbo_Applications"
                                ]
                            }
                        }
                    ],
                    "annotations": [{
                            "name": "PBI_ResultType",
                            "value": "Table"
                        }
                    ]
                }
            ],
            "cultures": [{
                    "name": "en-US",
                    "linguisticMetadata": {
                        "content": {
                            "Version": "1.0.0",
                            "Language": "en-US"
                        },
                        "contentType": "json"
                    }
                }
            ],
            "annotations": [{
                    "name": "PBI_QueryOrder",
                    "value": "[\"Applications\"]"
                }, {
                    "name": "__PBI_TimeIntelligenceEnabled",
                    "value": "1"
                }, {
                    "name": "PBIDesktopVersion",
                    "value": "2.137.1102.0 (24.10)"
                }, {
                    "name": "PBI_ProTooling",
                    "value": "[\"DevMode\"]"
                }, {
                    "name": "TabularEditor_SerializeOptions",
                    "value": "{\"IgnoreInferredObjects\":true,\"IgnoreInferredProperties\":true,\"IgnoreTimestamps\":true,\"SplitMultilineStrings\":true,\"PrefixFilenames\":false,\"LocalTranslations\":false,\"LocalPerspectives\":false,\"LocalRelationships\":false,\"Levels\":[\"Data Sources\",\"Shared Expressions\",\"Perspectives\",\"Relationships\",\"Roles\",\"Tables\",\"Tables/Columns\",\"Tables/Hierarchies\",\"Tables/Measures\",\"Tables/Partitions\",\"Tables/Calculation Items\",\"Translations\"]}"
                }, {
                    "name": "__TEdtr",
                    "value": "1"
                }
            ]
        }
    }




    • UmeshGoti's avatar
      UmeshGoti
      Icon for Helper I rankHelper I

      Hi i am able to create semantic layer with above json for model.bim but when dataset is created it is not connected with database(as i am connecting with azure database) because in above JSON we are not providing database credential details
      so can you please give updated JSON by which our semantic layer will also connected with mentioned database so we can have data fetched

      Thanks !!!

    • UmeshGoti's avatar
      UmeshGoti
      Icon for Helper I rankHelper I

      ddelapasse  can you please let us know how we can specify relationships when we have more than once tables for above JSON
      Thanks in advance !!