Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
15 replies
Subscribers
5 subscribers
Views
9362 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
Hello, has anyone managed to send a file with the HTTP request plugin? If yes, c
fabienb
A Score Level 1
over 11 years ago
Hello, has anyone managed to send a file with the HTTP request plugin? If yes, could you explain how to set the parameters? Thank you....
OriginalPostID-106410
OriginalPostID-106410
Discussion posts and replies are publicly visible
0
Stefan Helzle
A Score Level 3
over 11 years ago
That is quite easy. You encode the file to base64 and do a POST to the other server. Some headers have to be set, content-type and encoding at least. What kind of receiving server to you have? The exact procedure depends on this.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
Hi Stefanh, thanks for helping. The only specification I have is the curl function: $ curl -XPOST \\
-H "Authorization: token ${TOKEN}" \\
-F "file=@sample.txt" \\
api.xxxx.com/.../file
I have tried to encode 64 the file and pass it in the "body" input. How can I know what content type and encoding header I should set?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 11 years ago
stackoverflow.com/.../how-does-http-file-upload-work
This should help you. curl -F means that the data has to be sent as multipart/form-data.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
I tried to use multipart/form-data content type with convertdocumenttobase64(pv!Document) as Body input but I received the following message: {"code":"BadRequestError","message":"bad content-type header, no multipart boundary"}
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 11 years ago
You have to post something like this
POST /upload?upload_progress_id=12344 HTTP/1.1
Host: localhost:3000
Content-Length: 1325
Origin:
http://localhost:3000
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryePkpFF7tjBAqx29L
<other headers>
------WebKitFormBoundaryePkpFF7tjBAqx29L
Content-Disposition: form-data; name="MAX_FILE_SIZE"
100000
------WebKitFormBoundaryePkpFF7tjBAqx29L
Content-Disposition: form-data; name="uploadedfile"; filename="hello.o"
Content-Type: application/x-object
<file data>
------WebKitFormBoundaryePkpFF7tjBAqx29L--
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
Stefan, I am now using a new header ={"token TOKEN","multipart/form-data; boundary=--------"} with a new body: =concat("--------"",convertdocumenttobase64(pv!Document),"--------"). The error message is now:
{"code":"BadRequestError","message":"MultipartParser.end(): stream ended unexpectedly: state = START_BOUNDARY"} Do you have any thought? (sorry for bothering you like this)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
I did not see your message, I will try to build something like the example.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
Stefan, just to make sure, could you confirm for me that I should build the body with CONCAT and CHAR(13) like in :
=concat("----WebKitFormBoundaryePkpFF7tjBAqx29L",char(13),"Content-disposition: form-data;file=""file1""",char(13),"Content-type: text/plain",char(10),convertdocumenttobase64(pv!Document),char(13),"----WebKitFormBoundaryePkpFF7tjBAqx29L").
Thank you
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Stefan Helzle
A Score Level 3
over 11 years ago
Yes. That is how I would start. Do you have success with that? I recently had to adapt to a Deutsche Telekom SMS service that also included some hand crafted HTTP requests. It was not easy but after some trial an error it is working very good now.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
fabienb
A Score Level 1
over 11 years ago
Hello Stefan, thank you for your help really. I am getting closer. I got a new error message: {"code":"BadRequestError","message":"parser error, 9 of 114 bytes parsed"}.
My body is built as follows:
=concat("--AaB03x",char(13),"Content-disposition: form-data;name=""file"";filename=""aps.js""",char(13),"Content-type: application/octet-stream",char(13),"test",char(13),"--AaB03x--")
The problem is about the char(13). Do you have any idea?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>