REST API RAW POST

REST API RAW POST

  
Hi Guys,

I'm trying to send a PDF to a target php file with the REST API.
By creating a RAW post text I can send paramaters and the file in one request to the target page.

The PDF is on ANSI encoding but when I open the PDF received on the target php page it's UTF-8.
There for the PDF is not working anymore and I can get this to work.
This is the plaintext that I send trough the rest api:

-----------------------------261062025026036
Content-Disposition: form-data; name='printadres'

false
-----------------------------261062025026036
Content-Disposition: form-data; name='my_file'; filename='20161540.PDF'
Content-Type: application/pdf

 binarydatatotext(file)
-----------------------------261062025026036--
Hi Freek,

Why are you converting your binary data to text? That part of the content should be the actual binary.
See the Box Connector component in the forge for an example in the BoxContent_File\File_Upload action they create a binary content with multiplart like the one you need.

Regards,
João Rosado
Joao,

Correct me if I'm wrong but that is not true.
It should be the real data of the document.
The Rest API it selfs converts the text of the post to binary so in your case it will be converted 2 times.
The reveiver of the message does not a convert of the document itself.
Check your firefox if you upload a file.
There is no binary on the position of the file but the real data itself.

Greetz.
HI Freek,

"It should be the real data of the document" - Yes, it should be binary data of the document
"The Rest API it selfs converts the text of the post to binary so in your case it will be converted 2 times." - Partially true, but not all bytes of a pdf are valid utf-8 characters, so unless your pdf is 100% ascii (which is hard because the header usually contains non-ascii charecters) you will lose characters in that first conversion.
So how would you advice to do this, i can add the binary data with concat in the binary body. Only I can not add the binary data to the text body. Will this be a problem?
Just change the body input to binary like on the Box Connector example.
That will not work because the receiver is expection plain text in the body and not binary. I already tried that by doing this and its return the error that it can't find the object in the received post.
Hi,

It must work. What are you setting in the content type header?
"multipart/form-data; boundary=---------------------------"+Boundary

Boundary is a var: 
Substr(GeneratePassword(32,False),0,13)
Looks ok :(
Not sure what you are doing wrong.

I can at least guarantee you that the problem wont be from having a binary input instead of the text one.
The only difference between them (apart from the default content type header) is that the Text gets converted from String to Binary using utf-8 encoding before sent, while the Binary is just sent as is.

Regards,
João Rosado
freek wrote:
That will not work because the receiver is expection plain text in the body and not binary. I already tried that by doing this and its return the error that it can't find the object in the received post.
 Note that afaik binary is converted BASE64 (which is "plain text"). It's not the actual binary data that is sent across.