Skip to content

Unhandled Error when the OC API returns a non-json response body. #62

@oliverheywood451

Description

@oliverheywood451

In error situations when OC returns a raw string response body instead of a json response, the sdk method ThrowAuthExceptionAsync throws a not very helpful error "Object reference not set to an instance ....".

Here's code to re-create this error.

>             var oc = new OrderCloudClient(new OrderCloudClientConfig()
>             {
>                 ApiUrl = "https://sandboxapi.ordercloud.io/v1",
>                 AuthUrl = "https://sandboxapi.ordercloud.io/v1",
>                 ClientId = _settings.OrderCloudSettings.ClientID,
>                 ClientSecret = _settings.OrderCloudSettings.ClientSecret,
>                 Roles = new[] { ApiRole.FullAccess }
>             });
> 
>             var token = await oc.AuthenticateAsync();

The "/v1" in the url is incorrect and results in a response "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable." from OC.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions