BackgroundUploader thrown exception when response status code is 204 - No content

Gokul

New member
Joined
Oct 30, 2024
Messages
1
Programming Experience
1-3
I'm using BackgroundUploader and UploadOperation to upload a file to my server via API request, my API request is succeed with (204 - No content) status code, but a exception is thrown as `The operation was canceled by the user`. Rest of my API calls with (200) status code works good.

Code used - upload.StartAsync().AsTask(cts, progressCallback);

Need a fix.
 
My understanding is that you should be using:
C#:
await upload.StartAsync().AsTask(cts.Token, progressCallback);

But it maybe simply that you decide to not show us the await and that your cts is was truly the token, and not the token source.

Anyway, the first thing I would check is the value of cts.IsCancelRequested.

If it is set to true, then there you have it: the operation was truly cancelled by your code. Perhaps you are recycling a cts somewhere?

If it is set to false, then you'll need to do some troubleshooting to verify that connection is still valid. You may need to fire up WireShark or the equivalent.
 
Back
Top Bottom