Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

POST API request for file upload

sreejithmp
8 - Asteroid

Hi Data Folks,

 

Am using an api for uploading a file and it is working fine in postman not sure how can we achieve same in Alteryx using download tool. Could someone helps here. Below are the details 

In the body i have 2 parameters form_data which is a json object for payload and attachment which is the file to be uploaded. 

 

Headers contains: Content-Type :multipart/form-data

                               Cookie: Cookie

 post.png

 

25 REPLIES 25
apathetichell
20 - Arcturus

please post the error message. please post the new configuration of your download tool -> and a select tool which shows the field names/types going to the download tool. -> and confirm the file is at the path specified.

 

next try this -> rename your blob field 'file' - throw that in your form.

create a field name 'name' -> give it a name like 'test.pdf' -> or whatever your filetype is.

oneillp111
9 - Comet

no change with the name field

here is the error when I use 'file' instead of 'File'

 

HTTP/1.1 500
content-length: 0
content-type: application/json;charset=UTF-8
date: Wed, 15 Jan 2025 00:01:48 GMT
p3p: CP="NON CUR OTPi OUR NOR UNI"
x-content-type-options: nosniff
x-asessionid: 47pwn4
cache-control: no-cache, no-store, no-transform
x-xss-protection: 1; mode=block
x-ausername: xxxxxxxxxx
x-seraph-loginreason: OK
content-security-policy: sandbox
strict-transport-security: max-age=31536000; includeSubDomains
referrer-policy: strict-origin-when-cross-origin
x-anodeid: Node-tr-p19-b
x-arequestid: 61x3608978x1
Set-Cookie: JSESSIONID=258250DD46CA554BFBA36809C7202A65; Path=/tracker19; Secure; HttpOnly
Set-Cookie: atlassian.xsrf.token=BTGP-PE51-YAKD-HC0Q_e4059f064c24b94b20d7c50429b4b4127d5dd836_lin; Path=/tracker19; SameSite=None; Secure
Set-Cookie: BIGipServer~PART2492~RB-TRACKER-P19_21443=rd2492o00000000000000000000ffff0a3ae30co21443; Path=/; Secure; HttpOnly

 

patrick_digan
17 - Castor
17 - Castor

@oneillp111 If you use the download tool in alteryx, there is a lot of specific syntax that you would need to get just right. Postman and Curl take care of all this for you, but Alteryx doesn't have anything built in so far as I know. As an example, you can see the macro in this blog post which handles multi-part form data as part of the alteryx v3 endpoints: https://community.alteryx.com/t5/Engine-Works/Introducing-the-Alteryx-Server-v3-API/ba-p/899228

Specfically, there is a lot of logic packed into the buildrequestbody.yxmc for form data:

image.png

 

I built something similar, and here some highlights of the things to watch out for. I only got there in the end by using fiddler to compare the call in a swagger doc vs what I was sending in alteryx. 

1) you have to replace \n with \r\n:

image.png

2) You have to setup all the boundary information for the multi-part syntax in alteryx:

image.png

 

 

apathetichell
20 - Arcturus

Reminder ---> 'file' - not 'File' ---> @patrick_digan may be correct and I still don't have Alteryx set up locally to test this. I am 100% sure that this will not work with File vs file regardless.

 

Another weird note -> running this in app script -> I had to drop Content-Type entirely from the header to get this to work.

 

If this doesn't work -> I'd recommend just using the requests package in Python.

BrandonB
Alteryx
Alteryx

@oneillp111 is the Python tool an option for you? While it is possible in the Download tool you may find that using a simple python script is an easier route in this scenario. Example can be found here: https://community.alteryx.com/t5/Alteryx-Designer-Desktop-Discussions/Not-able-to-Upload-both-File-a... 

oneillp111
9 - Comet

I scratched the Download tool and went with a cURL command written into a batch file then executed through a run command tool.  Also did a work up with the python tool, which I started in the first place but wanted to see it through with the download tool.  

Labels
Top Solution Authors