Reply
BryanCarmichael
Helper II
Helper II

Unknown Error on Fabric Rest API getDefinition call on Semantic Model

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

token_string = mssparkutils.credentials.getToken("https://api.fabric.microsoft.com/")
header = {'Content-Type':'application/json','Authorization': f'Bearer {token_string}'}

addbody = {}


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)
1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

You used GET. This needs to be a POST call.

View solution in original post

4 REPLIES 4
BryanCarmichael
Helper II
Helper II

yes changed and resolved thank you 

v-pbandela-msft
Community Support
Community Support

Hi @BryanCarmichael,

Thank you for reaching out in Microsoft Community Forum.

Thank you @spencer_sa@lbendlin   for the helpful response.

As suggested by Spencer_sa,Ibendlin,  I hope this information was helpful. Please let me know if you have any further questions or you'd like to discuss this further. If this answers your question, please "Accept as Solution" and give it a 'Kudos' so others can find it easily.

Please continue using Microsoft community forum.

Regards,
Pavan.

spencer_sa
Super User
Super User

As an aside, if you're doing this in a Fabric notebook, you can use semantic-link-labs (aka sempy) with the FabricRESTClient class to do away with the whole 'Get Token' and request crafting malarky.
https://learn.microsoft.com/en-us/python/api/semantic-link-sempy/sempy.fabric.fabricrestclient?view=...
https://fabric.guru/using-fabricrestclient-to-make-fabric-rest-api-calls

If this helps, please consider Accepting as a solution to help other people find it more easily.

lbendlin
Super User
Super User

You used GET. This needs to be a POST call.

avatar user

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebFBC_Carousel

Fabric Monthly Update - February 2025

Check out the February 2025 Fabric update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)