SDK version used: Microsoft.Azure.Devices.Provisioning.Service Version="1.18.4"
Description of the issue
SDK fails to create enrollment group, fails with error:
Unhandled exception. Microsoft.Azure.Devices.Provisioning.Service.ProvisioningServiceClientHttpException: Bad Request:{"Message":"ErrorCode:ArgumentInvalid;Unknown api version; uri: /enrollmentGroups/EnrollmentGroupSample-4e4d1d9b-a277-4e1e-852d-45c1b57de4b4?api-version=2019-03-31","ExceptionMessage":"Tracking ID:97740FBD6F1F40798788E0C30ED1BAC4-G2:-TimeStamp:2024-12-02T22:46:44.613378812Z"}
➜ EnrollmentGroupSample git:(main) ✗ dotnet run -- -c "HostName=xxx"
Creating a new enrollment group...
Unhandled exception. Microsoft.Azure.Devices.Provisioning.Service.ProvisioningServiceClientHttpException: Bad Request:{"Message":"ErrorCode:ArgumentInvalid;Unknown api version; uri: /enrollmentGroups/EnrollmentGroupSample-4e4d1d9b-a277-4e1e-852d-45c1b57de4b4?api-version=2019-03-31","ExceptionMessage":"Tracking ID:97740FBD6F1F40798788E0C30ED1BAC4-G2:-TimeStamp:2024-12-02T22:46:44.613378812Z"}
at Microsoft.Azure.Devices.Provisioning.Service.ContractApiHttp.ValidateHttpResponse(ContractApiResponse response)
at Microsoft.Azure.Devices.Provisioning.Service.ContractApiHttp.RequestAsync(HttpMethod httpMethod, Uri requestUri, IDictionary`2 customHeaders, String body, String ifMatch, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.Provisioning.Service.EnrollmentGroupManager.CreateOrUpdateAsync(IContractApiHttp contractApiHttp, EnrollmentGroup enrollmentGroup, CancellationToken cancellationToken)
at Microsoft.Azure.Devices.Provisioning.Service.Samples.EnrollmentGroupSample.CreateEnrollmentGroupAsync() in /home/pkarpala/projects/DOW/azure-iot-sdk-csharp/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.cs:line 35
at Microsoft.Azure.Devices.Provisioning.Service.Samples.EnrollmentGroupSample.RunSampleAsync() in /home/pkarpala/projects/DOW/azure-iot-sdk-csharp/provisioning/service/samples/getting started/EnrollmentGroupSample/EnrollmentGroupSample.cs:line 23
at Microsoft.Azure.Devices.Provisioning.Service.Samples.Program.Main(String[] args) in /home/pkarpala/projects/DOW/azure-iot-sdk-csharp/provisioning/service/samples/getting started/EnrollmentGroupSample/Program.cs:line 41
at Microsoft.Azure.Devices.Provisioning.Service.Samples.Program.<Main>(String[] args)
Context
Description of the issue
SDK fails to create enrollment group, fails with error:
Looks like old API version is used?
2019-03-31
instead of2021-10-01
https://learn.microsoft.com/en-us/rest/api/iot-dps/service/enrollment-group/create-or-update?view=rest-iot-dps-service-2021-10-01#symmetrickeyattestationCode sample exhibiting the issue
Using code sample from this repository: https://github.com/Azure/azure-iot-sdk-csharp/blob/main/provisioning/service/samples/getting%20started/EnrollmentGroupSample/EnrollmentGroupSample.cs
Console log of the issue