List of Error Codes for IoTHub File Upload API

bcb44 86 Reputation points
2021-07-20T18:02:18.437+00:00

Hello,

I'm uploading files to Azure using the c# sdk. When I run the DeviceClient.CompleteFileUploadAsync() method, I sometimes get a System.ArgumentException that has a couple of different of error codes and messages. The main ones I've seen are "Bad Request", "Expired correlationID", and "Invalid correlation ID".
Is there a way for me to see all of the error messages and codes for the API?

Also, I handle different messages in different ways. Which are more consistent, the error codes or the error messages? My worry is because these aren't part of the sdk and I'm catching them based on the actual text based error message, they're going to update and my app will break. Any advice on this?

Here's my code
try {
await deviceClient.CompleteFileUploadAsync(createUploadInfo(corrId), cancelToken);
}
catch (ArgumentException ex) {
if (ex.Message.Contains("Bad Request")) {
//do action
}
else if (ex.Message.Contains("Expired correlation ID")) {
//do another action
}
else if (ex.Message.Contains("Invalid correlation ID")) {
//do another action
}
//alert user of break
}`

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
Azure IoT SDK
Azure IoT SDK
An Azure software development kit that facilitates building applications that connect to Azure IoT services.
228 questions
{count} votes

1 answer

Sort by: Most helpful
  1. David R. Williamson [MSFT] 26 Reputation points Microsoft Employee
    2021-08-03T17:31:06.43+00:00

    It looks like there is a bug in the service right now, where any malformed correlation Id will result in an HTTP status code of 500, which the SDK will turn into a ServerErrorException with a response body and exception message of:

    { "Message": "{\"errorCode\":500001,\"trackingId\":\"b18e47205f024726923046c53de3067d-G:0-TimeStamp:08/02/2021 18:27:03\",\"message\":\"InternalServerError\",\"timestampUtc\":\"2021-08-02T18:27:03.2607187Z\"}", "ExceptionMessage": "" }

    My contact on the service team will get a fix in, but I don't have an ETA yet.

    2 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.