0

ref. the query same subject of 17 June 2020 and relevant answer.

  1. ServiceException apparently is changed and now 'StatusCode' should be replaced by 'ResponseStatusCode'
  2. I tried to catch it in the procedure to upload large files:
        try
        {
            // Upload the file
            var uploadResult = await fileUploadTask.UploadAsync(progress);

            sb.AppendLine(uploadResult.UploadSucceeded
                ? $"Upload complete, item ID: {uploadResult.ItemResponse.Id}" 
                : "Upload failed");
        }
        catch (ODataError ex)
        {
            sb.AppendLine($"Error uploading: {ex.Error?.Message}");
        }
        catch(ServiceException ex)
        { 
            sb.AppendLine($"Service exception: {ex.Message}");
            sb.AppendLine($"StatusCode: {ex.ResponseStatusCode}");
            ex.
        }
        catch (HttpRequestException ex)
        {
            sb.AppendLine($"HttpException: {ex.Message}");
            sb.AppendLine($"HttpRequestError: {ex.HttpRequestError}");
            sb.AppendLine($"StatusCode: {ex.StatusCode}");
        }
        catch (Exception ex)
        {
            sb.AppendLine(ex.Message);
        }
        finally
        {
            result.Text = sb.ToString();
        }

Disconnecting the Internet during the upload, I expect should throw ServiceException - but it doesn't. HttpRequestException is thrown instead, but in this case: Message = “An error occurred while sending the request”, HttpRequestError = 0 (unknown), StatusCode = null

So I am stuck with the original query: hot to extract the HTTP status?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.