Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3667

Troubles sending binary file to rest API

$
0
0

I try send file to rest API, but service return error.

variables:  l_amount    INTEGER := 100;  l_pos       INTEGER := 1;  i number;  fSize      number; -- dbms_lob.getlength(myFile);  contLength number; -- fSize + length of request body service information  req       utl_http.req;  resp      utl_http.resp;code:url := 'https://tstmock.free.beeceptor.com/test1'; --test mock servicereq := utl_http.begin_request(url, 'POST');lBoundary := '----------------------------1234567890';utl_http.set_header(req, 'Content-Type', 'multipart/form-data;boundary='||lBoundary);utl_http.set_header(req, 'Content-Length',contLength); utl_http.set_header(req, 'accept-encoding','gzip, deflate, br'); utl_http.set_header(req, 'accept','*/*'); utl_http.set_header(req,'user-agent','Mozila/4.0');utl_http.write_raw(req, l_buffer);WHILE l_pos < f_size LOOP    dbms_lob.read(l_file, l_amount, l_pos, l_buffer);    stdio.put_line_buf(l_buffer);    utl_http.write_raw(req, l_buffer);    l_pos := l_pos + l_amount;            END LOOP;

request body:

----------------------------1234567890Content-Disposition: form-data; name="file"; filename="test.zip"Content-Type: application/zip*here content of zip file* ----------------------------1234567890--

this code work fine, and test mock server receive request normally. But!!! When i try send this file to https://file.io/ i receive error message:answer code = 400 {"success":false,"name":"ApiError","code":"FILE_MISSING","message":"No file or text data found","status":400,"help":"https://file.io/help/api/errors/FILE_MISSING","key":null}

when i try send this file from Postman utility, request body on free.beeceptor.com like as request from Oracle, but sending from Postman to https://file.io/ work fine.


Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>