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

Join the OneLake & Platform Admin teams for an ask US anything on July 16th. Join now.

Reply
bruparel
Microsoft Employee
Microsoft Employee

AI Skill works using UI but doesn't work when calling programmatically

I am trying to debug the Python code that a colleague wrote following the example given here:

 

https://learn.microsoft.com/en-us/fabric/data-science/ai-skill-scenario#use-the-ai-skill-programmati...

 

the code is really simple.  We just plugged in our URL and question and ran it.  Here is the code:

 

 

 

import requests
import json
import pprint
from synapse.ml.mlflow import get_mlflow_env_config


# the URL could change if the workspace is assigned to a different capacity
url = "https://msitapi.fabric.microsoft.com/v1/workspaces/65c73be1-bfdf-4683-812e-cab91cc98cbeNaN"

configs = get_mlflow_env_config()

headers = {
    "Authorization": f"Bearer {configs.driver_aad_token}",
    "Content-Type": "application/json; charset=utf-8"
}

#print (configs)
#question = "{userQuestion: \"Please list all providers\"}"
question = "{userQuestion: \"Please give me total number of claims in the claims.csv table\"}"
# question = "{userQuestion: \"Could you give me total cost of procedures done in year 2023 grouped by procedure code?\"}"

response = requests.post(url, headers=headers, data = question)
print ("I am here now")

print("RESPONSE: ", response)

#print("")

responsebody = json.loads(response.content)

print (responsebody)

#print(response["result"])

 

 

 

 

Here is the response:

I am here now
RESPONSE:  <Response [405]>
{'requestId': '9c739b23-d366-4c71-8fe2-4107e09cbf29', 'error...

 

the log shows no errors.  How do we go about debugging this script.  If anyone can help, that would ...

2 REPLIES 2
ighosh
New Member

I have the same issue, the difference I see is the trailing NaN in the URL, is it by design? 

ighosh_0-1732056942631.png

 

Anonymous
Not applicable

HI @bruparel,

I check the error message and I found it means the request method not allowed, you may need to check the api document to use allow methods to send these requests.

405 Method Not Allowed 

Regards,
Xiaoxin Sheng

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June FBC25 Carousel

Fabric Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors