Dev Space

Customize & extend the power of Alteryx. SDKs, APIs, custom tools, and more!

How to use Alteryx InputFiles API endpoint using Python?

avanibhatnagar
7 - Meteor

I want to embed an Alteryx Analytic App which is published on my Alteryx Server/Gallery on a separate portal. I have had some success with embedding the Alteryx Analytics App using Javascript & following this tutorial. The only issue is that Alteryx API to get questions does not support the file browser question unless you use the Input Endpoints API

I'm trying to use the Input Endpoints API to ;et the users upload a file. This is what I have tried the following so far:

url = 'http://alteryxserver../gallery/api/user/v2/inputfiles/'
payload = {}
files={'files':open(file_location,'rb')}
headers={               
'oauth_consumer_key':'...',
'oauth_signature_method':'HMAC-SHA1',
'oauth_signature':'...',
'Content-Type': 'multipart/form-data',
}
response=requests.post(url,headers, files=files)

On submitting this POST request I get the following error: b'{"data":null,"exceptionName":"BadRequestException","innerExceptionMessage":"","message":"Must specify subscription key (oauth_consumer_key parameter)."}'

It says "Must specify oauth_consumer_key_parameter" - but I'm already doing that, so I'm not able to troubleshoot the error appropriately.

 

I also tried using MultipartEncoder from requests_toolbelt-

m = MultipartEncoder(
fields={'files':open(file_location,'rb')})
response = requests.post(url, data=m,headers={'Content-Type': m.content_type, 'oauth_consumer_key':'...',
            'oauth_signature_method':'HMAC-SHA1','oauth_signature':'...'})

This also gives the same error

Any suggestions are appreciated!

0 REPLIES 0