You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a project for RecordPoint and I have to upload binaries to their API. The problem I encounter with the code below is that their API doesn't accept the Header Transfer-Encoding that is automatically set. I have asked them if they can solve this on their end but that could take a long time.
Example of XURL.post request var result = XURL.post("https://httpbin.org/post", File.openRead("c:/Projects/test.docx"));
To solve this I tried to create the body myself to prevent XURL.post from setting the Transfer-Encoding header (see code below). This workaround failed because the Content-Length header was automatically set and was based on the Base64 string and not on the number of bytes of the original file.
Example of workaround var file = File.openRead("c:/Projects/test.docx"); var body = "data:application/octet-stream;base64," :: Stream.getText(Encode.toBase64(file)); var result = XURL.post("https://httpbin.org/post", body);
All that said, it would be very helpfull if there is a way to disable XURL from automatically setting the headers to be more flexibel in these kind of situations.
The text was updated successfully, but these errors were encountered:
I'm currently working on a project for RecordPoint and I have to upload binaries to their API. The problem I encounter with the code below is that their API doesn't accept the Header Transfer-Encoding that is automatically set. I have asked them if they can solve this on their end but that could take a long time.
Example of XURL.post request
var result = XURL.post("https://httpbin.org/post", File.openRead("c:/Projects/test.docx"));
To solve this I tried to create the body myself to prevent XURL.post from setting the Transfer-Encoding header (see code below). This workaround failed because the Content-Length header was automatically set and was based on the Base64 string and not on the number of bytes of the original file.
Example of workaround
var file = File.openRead("c:/Projects/test.docx");
var body = "data:application/octet-stream;base64," :: Stream.getText(Encode.toBase64(file));
var result = XURL.post("https://httpbin.org/post", body);
All that said, it would be very helpfull if there is a way to disable XURL from automatically setting the headers to be more flexibel in these kind of situations.
The text was updated successfully, but these errors were encountered: