Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# ApiClient PrepareRequest FileParam ContentLenght problem #3555

Closed
glecchi opened this issue Aug 8, 2016 · 2 comments
Closed

C# ApiClient PrepareRequest FileParam ContentLenght problem #3555

glecchi opened this issue Aug 8, 2016 · 2 comments

Comments

@glecchi
Copy link

glecchi commented Aug 8, 2016

Description

Using a FormData request, in the method PrepareRequest of the ApiClient, when file is added to the request, RestSharp doesn't set the Content-Length.

foreach (var param in fileParams)
{
    request.AddFile(param.Value.Name,` param.Value.Writer, param.Value.FileName,    param.Value.ContentType);
}
Swagger-codegen version

Version 2.10.2

Suggest a Fix

At the time, the workaround i found was to modify the generated code and set the content length explicitly:

var index = 0;
foreach (var param in fileParams)
{
    request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
    request.Files[index++].ContentLength = param.Value.ContentLength;
}
@wing328
Copy link
Contributor

wing328 commented Aug 9, 2016

@glecchi is this the same issue as #2175?

@wing328 wing328 modified the milestones: v2.2.1, v2.2.2 Aug 9, 2016
@wing328
Copy link
Contributor

wing328 commented Aug 22, 2016

Closing this as there's no update.

@wing328 wing328 closed this as completed Aug 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants