FHIR Chat · How to receive REST Unauthorized Exception · dotnet

Stream: dotnet

Topic: How to receive REST Unauthorized Exception


view this post on Zulip Ken Miller (Aug 07 2021 at 20:38):

I've noticed that when I use an expired token with the SDK (v4, latest version), on a search or read operation, what gets thrown is an ArgumentNullException with message "Value cannot be null. (Parameter 'key')" instead of the expected authorization exception. Looking at the stack trace, the exception originates in the parsing subroutines. This is surprising, since the REST operation would have failed with a 401 error (which I've confirmed with Postman), so I don't know why the result is sent through for parsing. Is it possible that my FhirClient settings, which are permissive, are leading to this behavior? Obviously, I'd prefer to get the proper Authorization exception so I can provide the appropriate error message to the user and launch the process of getting a new token.

view this post on Zulip Ewout Kramer (Aug 09 2021 at 06:58):

The SDK will parse any non-null body. When it cannot not parsed, this will be caught and handled gracefully to return the raw contents - as a FhirOperationException. The fact that this is raises an ArgumentNullException means that you've found a bug in the handling here - something is happening that we are not expecting to happen, so we'd need to debug this. Can you file an issue here: https://github.com/FirelyTeam/firely-net-sdk/issues with as much information as you can so we can try to reproduce it?


Last updated: Apr 12 2022 at 19:14 UTC