okta / okta-sdk-dotnet

A .NET SDK for interacting with the Okta management API, enabling server-side code to manage Okta users, groups, applications, and more.
Other
160 stars 100 forks source link

Policy Api : _policyApiAsync.GetPolicyAsync fails and always sends 404 even when the Policy exists #704

Closed rishigohil closed 6 months ago

rishigohil commented 8 months ago

Describe the bug?

I am trying to retrieve the policy rule using _policyApiAsync.GetPolicyAsync but it always fails with 404 - Resource not found error even when Policy exists in the Okta org.

I went on to add Okta.Sdk project reference to troubleshoot the internal error and found that the code does retrieve the policy successfully but is not able to mount properly to Okta.Sdk.Model.Policy. It sends an exception while performing the serialization operation.

What is expected to happen?

GetPolicyAsync should return policy if it exists in the Okta Org

What is the actual behavior?

GetPolicyAsync fails with an internal exception

Reproduction Steps?

  1. Create a Policy Rule
  2. Use the Id to retrieve the same policy using _policyApiAsync.GetPolicyAsync or _policyApiAsync.GetPolicyWithHttpInfoAsync

Video showing the Internal Okta SDK Exception

https://github.com/okta/okta-sdk-dotnet/assets/5967748/9d7de3f3-7643-4155-96ed-a39930a634e6

Additional Information?

No response

.NET Version

.NET 6.0

SDK Version

7.0.5

OS version

BuildNumber Caption OSArchitecture Version 22621 Microsoft Windows 11 Enterprise 64-bit 10.0.22621

laura-rodriguez commented 8 months ago

Hi @rishigohil, Thanks for reporting this issue. Would you mind sharing the raw response as well?

rishigohil commented 8 months ago

When I perform the get call using GetPolicyWithHttpInfoAsync or GetPolicyAsync, I am receiving an exception with Error Content as follows: { "detail": "Requested resource could not be found.", "status": 404, "title": "Not Found" }

laura-rodriguez commented 8 months ago

Internal Ref: OKTA-710435

laura-rodriguez commented 7 months ago

Hi @rishigohil, I'm looking into this issue now and would appreciate additional information.

In the issue description, you mentioned you created a Policy Rule, but then you're using the _policyApiAsync.GetPolicyAsync () method to retrieve. If you want to retrieve a Policy Rule, use the GetPolicyRuleAsync method instead. For example:

var retrievedPolicyRule = await _policyApi.GetPolicyRuleAsync(createdPolicy.Id, createdPolicyRule.Id) as PasswordPolicyRule;

If you're actually trying to retrieve a policy, could you please share what type of policy is and the payload you get from the server?

Thank you!

laura-rodriguez commented 6 months ago

Closing this issue due to lack of activity. Feel free to reopen if this is still an issue.