-
Notifications
You must be signed in to change notification settings - Fork 34
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
MulitpartBody does not write out simple string values #300
Comments
Thanks for raising this @waynebrantley The issue here is essentially a duplicate of #247 (comment) that needs some investigation. The thing is that if we pass would you expect the payload to contain both key/values? Or just the values? multipartBody.AddOrReplacePart("Name", "application/x-www-form-urlencoded", "SomeName");
multipartBody.AddOrReplacePart("Address", "application/x-www-form-urlencoded", "SomeAddress"); If only values, does it make sense to change to this? multipartBody.AddOrReplacePart("Name", "text/plain", "SomeName");
multipartBody.AddOrReplacePart("Address", "text/plain", "SomeAddress"); |
Essential duplicate - sorry about that, I saw that ticket and thought it was all about the extra CRLF. Good question. If the type is x-www-form-urlencoded, then it would be expected to be key=value&key=value, etc. High level, we we expecting just the data to come out as it was form-data and was not sure how the encoded would work. We are really struggling getting an open api definition that kiota can call successfully, if that mapPost contains IFile and other data along with the file. Its either an open api generation issue (swashbuckle/nswag) or a kiota issue or both, it is a bit of a mess! :-) |
Thanks for the additional context. Out of curiosity, what are you using to generate the description? |
currently Swashbuckle. Cannot wait for the built-in openapi support. |
Thanks for confirming. Closing. |
Given code like this:
The parts inside MulitpartBody are correctly setup.
Serialize is called and this line of code executes: https://github.com/microsoft/kiota-dotnet/blob/main/src/abstractions/MultipartBody.cs#L148
As you can see it calls
partWriter.WriteStringValue(string.Empty, currentString);
and the first parameter of WriteStringValue is always empty. When writing out a form, that calls this code: https://github.com/microsoft/kiota-dotnet/blob/main/src/serialization/form/FormSerializationWriter.cs#L220If you look at this line
if(string.IsNullOrEmpty(key) || string.IsNullOrEmpty(value)) return;
, it is always true because the key is always empty!This results in none of the string values actually being written out.
The current tests you have around everything always mock out serialization library - so it does not reveal that it always calls with an empty string. Additionally, the tests for the FormSerializationWriter always pass in a key, so that does not reveal this issue either.
It appears that the Serialize code always passes empty key for all types of content so those are likely wrong too. In addition, this line effectively is a no-op also: https://github.com/microsoft/kiota-dotnet/blob/main/src/abstractions/MultipartBody.cs#L121
The text was updated successfully, but these errors were encountered: