Date Decoding error when calling AWSLocation.batchUpdateDevicePosition
phantumcode opened this issue · 1 comments
phantumcode commented
Description
Getting the following Swift.DecodingError.typeMismatch
error when calling AWSLocation batchUpdateDevicePosition via AWS Swift SDK with version 0.2.6 and version 0.3.0
Context
Updating Amplify Geo Category with support for updating device location via the AWSLocation service API batchUpdateDevicePosition
Environment
- AWS Swift SDK version used: 0.2.6, 0.3.0
- Operating System and version (iOS/macOS/Linux): iOS 15.5 and iOS 16 on iPhone 14 simulator
- Xcode version (if applicable): XCode 14
- Swift compiler version (if applicable):
- Swift Tools version (if applicable):
Reproduction Steps
let locationUpdates = [LocationClientTypes.DevicePositionUpdate(
accuracy: nil,
deviceId: "123-456-789",
position: [45.5, 44.4],
positionProperties: nil,
sampleTime: Date())]
let input = BatchUpdateDevicePositionInput(trackerName: tracker, updates: locationUpdates)
try await locationClient.batchUpdateDevicePosition(input: input)
Observed Behavior
API calls throws a error
client(ClientRuntime.ClientError.retryError(Swift.DecodingError.typeMismatch(Swift.Double, Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "Errors", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "SampleTime", intValue: nil)], debugDescription: "Expected to decode Double but found a string/data instead.", underlyingError: nil))), nil)
Expected Behavior
returns BatchUpdateDevicePositionOutputResponse
without an exception or error
Possible Solution
phantumcode commented
This is the http response I'm seeing when debugging into BatchUpdateDevicePositionOutputResponse
in the AWSLocation model:
{
DeviceId = "123-456-789";
Error = {
Code = ValidationError;
Message = "cannot parse timestamp";
};
SampleTime = "2022-10-04T04:21:50.352Z";
}