Describe the bug
After updating to v4.7.51 my client stopped to work.
System.Collections.Generic.KeyNotFoundException : The given key '3' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Refit.RequestBuilderImplementation.<>c__DisplayClass17_0.<<BuildRequestFactoryForMethod>b__0>d.MoveNext() in d:\a\1\s\Refit\RequestBuilderImplementation.cs:line 616
--- End of stack trace from previous location where exception was thrown ---
at Refit.RequestBuilderImplementation.<>c__DisplayClass14_0`2.<<BuildCancellableTaskFuncForMethod>b__0>d.MoveNext() in d:\a\1\s\Refit\RequestBuilderImplementation.cs:line 244
--- End of stack trace from previous location where exception was thrown ---
Steps To Reproduce
Create Refit client with method signature
[Multipart]
[Post("/companies/{companyId}/{path}")]
Task<ApiResponse<object>> UploadFile(
int companyId,
string path,
[AliasAs("file")] StreamPart stream,
[Header("Authorization")] string authorization,
bool overwrite = false,
[AliasAs("fileMetadata")] string metadata = null);
Expected behavior
Multipart file upload should work.
One part of the upload is a file stream
Second are form data
Environment
Additional context
Same bug here. Rollback to 4.7.9 fixes it. My implementation:
[Multipart]
[Post("/blobstorage/{**filepath}")]
Task Blob_Post_Byte(string filepath, [AliasAs("attachment")] ByteArrayPart byteArray);
You are very lucky that you could rollback :) It won't work in my case. 4.7.51 is already used in multiple other nugets in my company. I had to switch to classic typed HttpClient for upload scenarios.
Later I read that putting StreamPart on the first position of the arguments list works fine
Thanks @ppasieka. That fixed it. Been battling with it for hours
I have the same problem with version 4.7.9 for this request
[Delete("/api/v1/video")]
Task Clear([Query] int playerIndex);
I have to stay on version 4.6.107
I'm going to get this pushed to NuGet shortly but please validate that the fixes work for you in 4.8.10 or later -- the package is on the CI feed:
https://pkgs.dev.azure.com/dotnet/ReactiveUI/_packaging/Refit/nuget/v3/index.json
Thanks @onovotny.
I can confirm that v4.8.10 fixed this bug for me 馃檶
Just for reference, here is my code that was failing on v4.7.51 and now works on v4.8.10:
[Post("/PostBlob/{photoTitle}"), Multipart]
Task<PhotoModel> PostPhotoBlob(string photoTitle, [AliasAs("photo")] StreamPart photoStream);
Fixed by #772
Most helpful comment
Same bug here. Rollback to 4.7.9 fixes it. My implementation: