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

Error of Deserialize with CreateAsync when salesforce return error #391

Open
Oberown opened this issue Nov 3, 2020 · 0 comments
Open

Error of Deserialize with CreateAsync when salesforce return error #391

Oberown opened this issue Nov 3, 2020 · 0 comments

Comments

@Oberown
Copy link

Oberown commented Nov 3, 2020

Hello,

When I use CreateAsync and salesforce return a error.
Salesforce return this

{
    "hasErrors": true,
    "results": [
        {
            "referenceId": "Id 1",
            "errors": [
                {
                    "statusCode": "STRING_TOO_LONG",
                    "message": "TotoId: data value too large: AzertyAzerty (max length=5)",
                    "fields": [
                        "TotoId__c"
                    ]
                }
            ]
        }
    ]
}

But the error message is parsed in ErrorResponses , but is not the good format.
It make an exception of Deserialise not an exception with the salesforce message.

private static ForceException ParseForceException(string responseMessage)
        {
            var errorResponse = JsonConvert.DeserializeObject<ErrorResponses>(responseMessage);
            return new ForceException(errorResponse[0].ErrorCode, errorResponse[0].Message);
        }

You're welcome.

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