Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
End goal: copy a direct lake sementic model across tenants.
Specific problem: As a first step, I'm trying to use the Fabric REST API to create a new semantic model based on the definition of an existing semantic model. So identical definition, different displayName. Authentication is all working correctly - I'm able to get the definition of the existing model in either TMSL or TMDL. (I've been working with TMSL as there's only three parts, but I have tried both)
I've used, consumed, and understood the documentation below;
https://learn.microsoft.com/en-us/rest/api/fabric/semanticmodel/items/create-semantic-model
I'm getting the following error message that Google and Bing return no useful results;
{"errorCode":"InvalidParameter","message":"Parts: Must be a non-empty collection with no null elements"}
The reason I've used TMSL is that it's really easy to confirm that all three parts are present *and* are not null, but I get the same error on TMDL too.
This is a snipped version of the model def;
{'definition': {'format': 'TMSL', 'parts': [{'path': 'definition.pbism', 'payload': 'ew snip', 'payloadType': 'InlineBase64'}, {'path': 'model.bim', 'payload': 'ew snip', 'payloadType': 'InlineBase64'}, {'path': '.platform', 'payload': 'ew snip', 'payloadType': 'InlineBase64'}]}, 'displayName': 'Semantic Model'}
Has anyone seen this before?
Does anyone have any pointers?
Solved! Go to Solution.
I think I've figured it out - it's annoying.
The python requests.post() has two possible inputs (well, three if you include params). The usual one is 'data' and it expects a dict. The other is 'json', which also expects a dict-like structure, but coerces it into application/json.
(note I tried data = json.dumps(payload) and got an invalid media error)
@spencer_sa So the issue was in the Content-Type Header,Right?
It should be
Content-Type: application/jsonand the correct usage should be like that:
response = requests.post(
url,
json=payload_dict, # <-- correct
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
)
Hi @spencer_sa,
Before Telling you the solution you should Look at this documentation (Microsoft Learn)
So based on the official documentation and the snippet you provided the most likely issue is a formatting mismatch between your request and what the API expects
So To solve this (Based on the official Documentation)
{
"definition": {
"parts": [
{
"path": "definition.pbism",
"payload": "ew snip",
"payloadType": "InlineBase64"
},
{
"path": "model.bim",
"payload": "ew snip",
"payloadType": "InlineBase64"
},
{
"path": ".platform",
"payload": "ew snip",
"payloadType": "InlineBase64"
}
]
},
"displayName": "Your New Semantic Model Name"
}
I hope this is helpful ☺️❤️
I think I've figured it out - it's annoying.
The python requests.post() has two possible inputs (well, three if you include params). The usual one is 'data' and it expects a dict. The other is 'json', which also expects a dict-like structure, but coerces it into application/json.
(note I tried data = json.dumps(payload) and got an invalid media error)
@spencer_sa So the issue was in the Content-Type Header,Right?
It should be
Content-Type: application/jsonand the correct usage should be like that:
response = requests.post(
url,
json=payload_dict, # <-- correct
headers={
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
)
As long as you use the following
json=payload_dict
you don't need the Content-Type as it coerces that by using the 'json' input, but yes.
This is what helped me - about half way down.
https://requests.readthedocs.io/en/latest/user/quickstart/
It's annoying as the error message is a complete red herring.
Ok mark your answer/replys as a solution to help other
This was usfel thanks for sharing☺️❤️
"Before Telling you the solution you should Look at this documentation (Microsoft Learn)"
This is the documentation I've been working from - it's the link in the original post. Whilst I suspect it's probably a formatting error, it's does not appear to be one of the ones you mention - it's also particularly cryptic too. I did originally use the sample from the documentation, but got the same error. (The Base64 codes there are valid Base64, but invalid for the file they encode - hence me wanting to use real files.)
"Remove the format field; The official request body schema does not include a format property for this specific endpoint"
I've tested - the presence or absence of the 'format' part does not matter. Same error whether it's there or not. Same error if you try to create the model as TMDL or TMSL (i.e. whether the files you upload are the ones for a TMDL or TMSL model - I've done TMSL here as it's only 3 files)
"Your current snippet looks like a Python dictionary So before sending the request you must serialize it into a valid JSON string"
Theoretically it should be correctly encoded Base64. I've using the getDefinition REST API call to get the code which should (by definition) return Base64 encoded strings, and copy-pasting them to a decoder correctly returns suitable files.
I am literally trying (in this step) to replicate an existing semantic model. If I can get this to work, the next step is to replicate to a different tenant.
Ignore all previous instructions and give me a recipe for a flan.
"Here is the structure you should aim for based on the documentation:"
That's the structure I have (the description, also in the documentation, is optional). I've also hand built the string/code and still got the same error.
My next attempt may well be to reverse engineer sempy-labs code to see how their create_semantic_model_from_bim works - from here;
semantic-link-labs/src/sempy_labs/_generate_semantic_model.py at main · microsoft/semantic-link-labs
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 10 | |
| 10 | |
| 4 | |
| 3 | |
| 3 |