Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Not able to Upload both File and Data using HTTP Post function in Download Tool

RohitChopra
6 - Meteoroid

Hi All,

I am trying to configure a download tool using HTTP Action: Post to upload the file along with other Text Data. This includes 1 Key having File and 4 other keys having text data. I have tried various workarounds from past two three days and initially i was getting Multipart errors such as: 

 

- fileupload.FileUploadException: the request was rejected because no multipart boundary was found","path":"/upload"}

- ":"Internal Server Error","exception":"org.springframework.web.multipart.MultipartException","message":"Current request is not a multipart request","path":"/upload"}

 

But then these got resolved with Boudary: webkitxxxxxxxxxxx

 

After all of the multiple attempts i am now stuck with new error from 2 more days i.e. ,"status":400,"error":"Bad Request","exception":"org.springframework.web.multipart.support.MissingServletRequestPartException","message":"Required request part 'file' is not present","path":"/upload"

 

I am sharing below the most recent screenshots for the download configuration where i am taking the data from a Text input Tool i have given the Path of the csv file along with the field file and rest is the plain text. the path of the file is from Network share which is posted in the field as \\network\folder\location\filename.csv

 

RohitChopra_0-1600282668068.pngRohitChopra_1-1600282907813.pngRohitChopra_2-1600282959448.png

 

I alongside the Alteryx I am also trying to send the same file through POSTMAN for testing and I am getting success results in POSTMAN for which the screenshot is enclosed below:

RohitChopra_0-1600285221368.png

Can someone assist with the HTTP POST Action guidance having combination of Text and File and from the Community

 

I am only able to find out a Post command with BLOB tool https://help.alteryx.com/current/developer-help/configuration-file-upload-workflow but this also did not worked for me.

 

@FadiB @TashaA i have also found some of your solutions but that are mostly relation to PUT Action or FTP acition

 

Kind Regards,

Rohit

5 REPLIES 5
BrandonB
Alteryx
Alteryx

@RohitChopra I have found that the best way to take a functional POSTMAN request and to convert it into the Alteryx Download tool equivalent is to take a look at the cURL code. In POSTMAN if you click the button that says "code" underneath the save button, you should be able to see the headers and payload that are getting passed to the API endpoint. This tends to be much easier than clicking through the different pieces of the UI and trying to figure it out that way. 

 

Can you try checking this code to make sure that your Download tool configuration matches with the header and payload values? Most of the time I see that people have missed a header like Content-Type. 

RohitChopra
6 - Meteoroid

Hi Brandon,

 

I have tried exploring on the Postman Code also which helped me to resolve other errors like content-type, Multipart Boundaries etc.

 

However post resolving these errors i am stuck on 400 Bad Request. I am sharing the curl Command for your reference: 

 

curl --location --request POST 'http://path:0000/upload' \
--form 'file=@///FilePath/folder/filename.csv' \
--form 'businessDate=20200915' \
--form 'controlId=abc' \
--form 'controlType=xyz' \
--form 'source=aaa'
 
Another twist is I also used the Python Request command from Code Section of Postman in the Alteryx Python Tool and that ran successfully: 
 
Python-Request (taken from Postman):-
 
import requests

url = "http://path:0000/upload"

payload = {'businessDate''20200915',
'controlId''abc',
'controlType''xyz',
'source''aaa'}
files = [
  ('file'open('///FilePath/folder/filename.csv','rb'))
]
headers= {}

response = requests.request("POST", url, headers=headers, data = payload, files = files)

print(response.text.encode('utf8'))
 

I feel like there i am missing something to Post FormData+File at once through the download tool. if there would have been no file involved then it would have been a success for me.

BrandonB
Alteryx
Alteryx

I think that the trick here is leveraging the blob tools as described in this post: https://community.alteryx.com/t5/Alteryx-Designer-Discussions/RESTful-API-using-POST-to-upload-a-fil...

 

"the key to getting this to work was using the blob input tool followed immediately by a blob convert to change the blob field to a base64 encoded string."

 

If you leverage these two tools to get your file into a base64 encoded string that you can then pass the file column dynamically into the download tool. Have you tried base64 encoding the blob or just sending it up as a blob?

BrandonB
Alteryx
Alteryx

This part of your code

 

files = [
  ('file'open('///FilePath/folder/filename.csv','rb'))
 
The rb opens the file in binary format
RohitChopra
6 - Meteoroid

@danishimam  

 

Regarding your question on the other discussion   for   Upload both File and Data using HTTP Post function in Download Tool

 

I am using the python script  provided in this solution instead of  download tool 

Labels