API in Streamlit
![TH99](https://us.v-cdn.net/6038231/uploads/Dataiku/nAvatar15.png)
Hello,
While post requesting in streamlit (Code Studio) , I keep receiving the same error : {"errorType":"com.dataiku.dip.io.SocketBlockLinkKernelException","message":"Failed to run function : \u003cclass \u0027TypeError\u0027\u003e : api_py_function() missing 3 required positional arguments: \u0027file_bytes_io\u0027, \u0027question\u0027, and \u0027ConversationID\u0027","detailedMessage":"Failed to run function : \u003cclass \u0027TypeError\u0027\u003e : api_py_function() missing 3 required positional arguments: \u0027file_bytes_io\u0027, \u0027question\u0027, and \u0027ConversationID\u0027","detailedMessageHTML":"\u003cspan\u003e\u003cspan class\u003d"err-msg"\u003eFailed to run function : \u0026lt;class \u0027TypeError\u0027\u0026gt; : api_py_function() missing 3 required positional arguments: \u0027file_bytes_io\u0027, \u0027question\u0027, and \u0027ConversationID\u0027\u003c/span\u003e\u003c/span\u003e".
Although I'm passing the 4 required parameters of the api function:
files = {
'file_bytes_io': (uploaded_file.name, bytes_data, uploaded_file.type)
}
# Prepare the data dictionary to include additional parameters
data = {
'question': question,
'filename': uploaded_file.name,
'ConversationID': ConversationID
}
response = requests.post(api_url, files=files, data=data, auth=HTTPBasicAuth(api_key, password))
What could be my problem here?
Answers
-
Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,211 Dataiker
Hi,
the error suggests the params you are passing don't match the api_py_function define
api_py_function() missing 3 required positional arguments:
From what I can tell you are expecting -> file_bytes_io but are passing "filename".
Can you share a snippet of your api_py_function.Thanks