Integration Problem

ajay.munjal's Avatar


14 Mar, 2011 10:17 AM

hi marc,

I use your Sample codes to integrate CheddarGetter to my Application.if any error occur while inserting data into CheddarGetter .how can I show that error on particular field.Your api returns only

412 Precondition Failed: The request contains POST data that is in an invalid format or required parameters are missing.

Please Let us know about the Solution

  1. Support Staff 1 Posted by Marc Guyer on 14 Mar, 2011 03:47 PM

    Marc Guyer's Avatar

    The error response contains information about the error. More information here:

  2. 2 Posted by ajay.munjal on 15 Mar, 2011 01:20 PM

    ajay.munjal's Avatar

    Hi Marc,

    Thanks For your quick reply.
    But I am still suffering from same problem .Can you provide me the sample where i will get error code with specific error.Currently i am in progress of integrating your api to our application.I am deliberately Putting entry and I got only Error Code 412 .
    "Precondition Failed: The request contains POST data that is in an invalid format or required parameters are missing.". I am Unable to get that Specific error Such as first name is missing or credit card is not accepted.

    Please Give me the full Techical desciption and Sample of That particular Part .

  3. Support Staff 3 Posted by Marc Guyer on 15 Mar, 2011 01:39 PM

    Marc Guyer's Avatar

    Which operating system are you using? Which programming language are you using? Which API wrapper are you using?

  4. 4 Posted by ajay munjal on 15 Mar, 2011 05:14 PM

    ajay munjal's Avatar

    OpeartingSystem :- Windows 7

    Programming Language:- ASP.NET

    API Wrapper:- c#

  5. 5 Posted by ajay.munjal on 16 Mar, 2011 03:41 AM

    ajay.munjal's Avatar

    OpeartingSystem :- Windows 7

    Programming Language:- ASP.NET

    API Wrapper:- c#

  6. 6 Posted by ajay.munjal on 16 Mar, 2011 03:47 AM

    ajay.munjal's Avatar

    Please Reply me as early as Possible .so that i am able to integrate it...

  7. Support Staff 7 Posted by Marc Guyer on 16 Mar, 2011 02:59 PM

    Marc Guyer's Avatar

    Hi John -- Would you mind weighing in on how to get the error details out of your wrapper?

  8. 8 Posted by John on 16 Mar, 2011 03:25 PM

    John's Avatar

    Hi Marc and Ajay,

    I am actually in the process of moving this wrapper to GitHub so that others can improve on it, but in the meantime an example of how you can extract detailed error information can be found in the getCustomerList() method (roughly line 800) in CheddarGetter.cs.

    You will see the variable instantiation of List errorList = new List();
    Down at the bottom of that method you can see the following population of error codes from the response:

                errorList = (from e in customersXML.Descendants("errors")
                             select new CGError
                                 ID = (string)e.Attribute("id"),
                                 Code = (string)e.Attribute("code"),
                                 AuxCode = (string)e.Attribute("auxCode"),
                                 Message = (string)e.Element("error")

    This is not implemented everywhere, but it could be where ever it is available in the response.

    Hope this helps.


  9. 9 Posted by John Siladie on 16 Mar, 2011 05:37 PM

    John Siladie's Avatar

    Hey guys,

    I just created a repository on GitHub for this. You can find it here:

  10. 10 Posted by ajay.munjal on 17 Mar, 2011 04:10 AM

    ajay.munjal's Avatar

    hi John Siladia,

    Thanks for helping me.But on Create customer or Update customer I am not getting error from your api wrapper .Please reply me how can i get that particular error on creating and updating customer.I am not getting any response from your API or any xml containing error code and auxcode.Please Help me in case of create and update customer.For Example on creating a customer if first name is missing ,or credit card is not accepted Your api will return such error.but it returns

    412 Precondition Failed: The request contains POST data that is in an invalid format or required parameters are missing.

    Regards ,

    ajay munjal

  11. 11 Posted by John Siladie on 17 Mar, 2011 08:33 PM

    John Siladie's Avatar


    I see what you're saying and that is happening in postRequest() on the following line:

    using (WebResponse response = request.GetResponse())

    it ends up throwing an exception and that 412 Precondition Failed is all that returns from that. I am sure this can be improved, but I honestly don't have the time to do it at the moment. It'd be awesome If you want to check it out of GitHub and improve on it.


  12. 12 Posted by Alexander Kenne... on 28 Mar, 2011 01:38 PM

    Alexander Kenney's Avatar

    Firstly a huge thank you to the work that John has put in to the C# wrapper. It has made the work that we are doing that much smoother. Thank you wherever you are!

    We are currently integrating Cheddar Getter into our latest online offering at the moment and have come up against this exact issue. At the moment we are undecided on the best way to enhance John's work so that we can get hold of the exact CG error xml. So what I am about to say is subject to change at our end.

    However here are a couple of pointers.

    When Creating a Customer in CG, the CreateCustomer() method is called, which in turn calls the private postRequest().

    postRequest Mods:
    Look at the postRequest method in CheddarGetter.cs and go to the 'catch' handler. Instead of simply returning the error message as per the current code (412: Precondition etc), you can extract the CG xml response by using:

    StreamReader reader = new StreamReader(ex.Response.GetResponseStream());
    result = reader.ReadToEnd();

    This extracts the xml response you are looking for allowing the CreateCustomer() method to receive and work with it. The CreateCustomer() method already looks for these errors in the following line:

    customers = getCustomerList(newCustomerXML);

    Then you just need to add an extra couple of lines that check to see if the customers.ErrorList is greater than 0 and throw an exception if it is.

    We are right at the start looking at this issue in the code, so please treat this advice cautiously.


  13. Support Staff 13 Posted by Marc Guyer on 28 Mar, 2011 02:22 PM

    Marc Guyer's Avatar

    Alex -- thanks very much for weighing in here. We'd very much like to see this improvement in the C# wrapper as well. Error handling is a big piece of the puzzle. As such, I'd like to bring one item to everyone's attention:

    There are (unfortunately) two different general scenarios which produce two different error response formats. Maybe more than 80% of the time, the error will be returned in a single error node xml response. The other 20% of the time, the error message is embedded in the customer response. The two general scenarios are 1) customer never existed -- error occurs on signup, and 2) customer already exists prior to error occurrence.

    This KB article spells it out:

    We haven't looked at the C# code enough to know how the second scenario is handled but thought it would be good to bring up because it's easy to miss.

  14. 14 Posted by Alexander Kenne... on 28 Mar, 2011 02:58 PM

    Alexander Kenney's Avatar

    Marc -- we did notice that sometimes we get ...


    and sometimes ...


    We are working out a way to handle these scenarios, but it would be a great help if CG just returned the top scenario in all cases. This way all the integration code libraries could be simplified somewhat.

    Once we have decided on our approach to error handling during the C# / CG communication we will let everyone know.


  15. Support Staff 15 Posted by Marc Guyer on 30 Mar, 2011 03:45 PM

    Marc Guyer's Avatar

    In hindsight it might have been cleaner to have a common error format for every case. However, it is what it is. In order to maintain backward compatibility, it must remain as is. It could be argued that the embedded error type is beneficial since it indicates that the customer exists.

  16. Dean closed this discussion on 16 Jan, 2013 04:22 PM.

Discussions are closed to public comments.
If you need help with Cheddar please start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac

Recent Discussions

28 Mar, 2024 10:45 PM
24 Jan, 2024 08:33 AM
11 Jan, 2024 07:13 AM
30 Nov, 2023 02:07 AM
22 Nov, 2023 08:41 AM