Hi
I have a service in order to process a file.
I received a file.
When I use PostMan, work fine.
But, when I use swagger, the file came with some caracters strangers to me.
In the begin of file
"------WebKitFormBoundaryJjjj4q1PAAqcY5Ou
Content-Disposition: form-data; name="Input"; filename="CN27110A.RET"
Content-Type: application/octet-stream"
And in the end...
'------WebKitFormBoundaryJjjj4q1PAAqcY5Ou--'
Hi.
I send the file trought swagguer;
The code below is the service whitch receive the data and when I call the function "LerRetorno", a exception is raised because there is "dirt" in file.
"
function TBoletoService.ProcessarArqRetorno(ArquivoRetorno: TStream): TResultArqRetornoDTO;
var AcBrBoleto : TAcBrBoleto;
ImpressaoBoleto : TACBrBoletoFCFortes;
LStream: TFileStream;
nCount: Integer;
DadosRetornoArq: TItemResultArqRetornoDTO;
"
The begin of file, on the first line is
"02RETORNO01COBRANCA 073100785150 FA"
When I received became this
"------WebKitFormBoundarywqxnhABaPIaVkn9Q
Content-Disposition: form-data; name="Input"; filename="CN27110A.RET"
Content-Type: application/octet-stream"
Why the file are changing their content?
If you want more details, I can send to your email. There is some non public informations, so if you want, I can send in your e-mail thel all details.
That's a limitation of Swagger-UI, that's how it sends files to the server. It sends files in multipart/form-data format. That's why it adds that extra information to the file content.
So either your XData service handle that format, or you can't use Swagger-UI.
Hi.
Understood
How can I handle this? There is a way? How I clear this? Or the problem is in the origin of requisition? If yes, which type of requisition we must work?
It's not a "problem", but a limitation. SwaggerUI sends files in multipart/form-data format. If you want to handle that at XData side, you need to handle such content type.
You must check if content-type header is multipart/form-data, and if it is, you should handle the TStream considering the extra information sent by Swagger-UI.