Forum Discussion
Anonymous
1 year agoNot applicable
Fabric RestAPi GetDefinition on Semantic model returns Unknown Error
Hi - running into an issue trying to get the defintion of a Semantic Model in a notebook.
Note that the parameters are correct as if i drop the /getDefinition from the end I get results back as expected for the Semantic Model.
Code in notebook below
import requests
import json
header = {'Content-Type':'application/json','Authorization': f'Bearer {token_string}'}
addbody = {}
addURL = 'https://api.fabric.microsoft.com/v1/workspaces/XXXXXXX/semanticModels/YYYYYY/getDefinition'
add_Response = requests.get(addURL,headers=header, data=json.dumps(addbody))
from pyspark.sql import SparkSession
from pyspark.sql import Row, Column
from pyspark.sql.functions import col, year, regexp_replace
# Initialize Spark Session
spark = SparkSession.builder.appName("JsonToDelta").getOrCreate()
# Extract the list of results
sourceData =add_Response.json()
print(sourceData)
Hope this will resolve the error
4 Replies
- nilendraFabricSuper User
Hello Anonymous
The error occurs because the Fabric REST API’s `getDefinition` endpoint for semantic models requires a POST request instead of GET.
try thisadd_Response = requests.post(addURL, headers=header)
if this is helpful please accept the answer
- AnonymousNot applicable
nilendraFabric - thanks for that - now I feel really stupid for not spotting it was a POST rather than a GET method 🙂
- nilendraFabricSuper User
Hope this will resolve the error