Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the library take into account that the API can return an Fault with 200 OK code? #259

Open
pavel-dushkov-am opened this issue Oct 4, 2022 · 0 comments

Comments

@pavel-dushkov-am
Copy link

pavel-dushkov-am commented Oct 4, 2022

Preface:

We got an error because the method DataService.Upload

public Attachable Upload(Attachable entity, System.IO.Stream stream)

returned null.

It turned out that this is due to the fact that the API returned an error with a 200 OK code.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<IntuitResponse xmlns="http://schema.intuit.com/finance/v3" time="2022-09-28T14:52:37.164-07:00">
    <AttachableResponse>
        <Fault type="ValidationFault">
            <Error code="6000" element="">
                <Message>A business validation error has occurred while processing your request</Message>
                <Detail>Business Validation Error: Unexpected Internal Error. (-30000)</Detail>
            </Error>
        </Fault>
    </AttachableResponse>
</IntuitResponse>

(error that was returned by API)

And since the DataService.Upload doesn't handle cases where the response is Fault,

IntuitResponse restResponse = (IntuitResponse)CoreHelper.GetSerializer(this.serviceContext, false).Deserialize<IntuitResponse>(response);
this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Add.");
foreach (AttachableResponse returnEntity in restResponse.AnyIntuitObjects)
{
return returnEntity.AnyIntuitObject as Attachable;
}
return null;

it returned null, and didn't provide any information about error.

Question:

Given that returning an error with a 200 OK code is normal for an API (docs),
image

the question arises: is this behavior of the library intentional, or is it a bug?
Just for example - why we don't do something like this - #260

IntuitResponse restResponse = (IntuitResponse)CoreHelper.GetSerializer(this.serviceContext, false).Deserialize<IntuitResponse>(response);
this.serviceContext.IppConfiguration.Logger.CustomLogger.Log(Diagnostics.TraceLevel.Info, "Finished Executing Method Add.");
foreach (AttachableResponse returnEntity in restResponse.AnyIntuitObjects)
{
switch (returnEntity.AnyIntuitObject)
{
case Attachable attachable:
{
return attachable;
}
case Fault fault:
{
var exception = IterateFaultAndPrepareException(fault);
if (exception is not null)
{
throw exception;
}
break;
}
}
}
return null;

(Similar case from PHP library - intuit/QuickBooks-V3-PHP-SDK#413)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant