Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
BryanCarmichael
New Contributor III

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
Esteemed Contributor III

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

View solution in original post

5 REPLIES 5
lbendlin
Esteemed Contributor III

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

ssap
New Contributor

thank you!  this helped me greatly

spencer_sa
Contributor III

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.

Anonymous
Not applicable

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.

BryanCarmichael
New Contributor III

yes changed and resolved thank you 

Helpful resources

Announcements
Users online (25)