Survey banner
Switching to Dataiku - a new area to help users who are transitioning from other tools and diving into Dataiku! CHECK IT OUT

API in Streamlit

TH99
Level 2
API in Streamlit

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?

0 Kudos
1 Reply
AlexT
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

0 Kudos