Precondition Failed: planId|planCode required

Jon Larkowski's Avatar

Jon Larkowski

24 Aug, 2009 08:48 PM

Howdy, having trouble creating a new customer via the API. Running out of ideas here... We've tried adding planId and planCode everywhere we can think of, yet we still receive this error:

#<CheddarGetter::Response:0x252982c @responseType="error", @document=<?xml version="1.0" encoding="UTF-8"?> <error code="412">Precondition Failed: planId|planCode required.</error>

Here's the hash we're giving to Request#newCustomer:

{"lastName"=>"Customer",
 "code"=>"EXAMPLE_CUSTOMER",
 "planId"=>"722103ea-e229-102c-a92d-40402145ee8b",
 "planCode"=>"PLUS",
 "firstName"=>"Example",
 "subscription"=>
  {"ccZip"=>"90210",
   "ccNumber"=>"4111111111111111",
   "planId"=>"722103ea-e229-102c-a92d-40402145ee8b",
   "planCode"=>"PLUS",
   "ccLastName"=>"Customer",
   "ccFirstName"=>"Example",
   "ccExpiration"=>"04-2011"},
 "email"=>"[email blocked]"}
  1. Support Staff 1 Posted by Marc Guyer on 24 Aug, 2009 08:56 PM

    Marc Guyer's Avatar

    The customer information is just basic stuff: name, email, code. The subscription array is the meat. The planCode must be part of that subscription array.

  2. Marc Guyer closed this discussion on 24 Aug, 2009 08:56 PM.

  3. Support Staff 2 Posted by Marc Guyer on 24 Aug, 2009 09:01 PM

    Marc Guyer's Avatar

    That error message doesn't make it clear. I've added a todo item to make it clearer. Thanks for bringing this up!

  4. Jon Larkowski re-opened this discussion on 24 Aug, 2009 09:14 PM

  5. 3 Posted by Jon Larkowski on 24 Aug, 2009 09:14 PM

    Jon Larkowski's Avatar

    We do have planCode in the subscription array, but it's still throwing the error. Could we maybe see an example of valid low-level POST data for the /customers/new/productCode/MY_PRODUCT_CODE action?

  6. Support Staff 4 Posted by Marc Guyer on 24 Aug, 2009 10:30 PM

    Marc Guyer's Avatar

    I see now that you have the planCode in the subscription nested hash. I saw it in the root hash and stopped looking. It might be an issue with HTTParty handling the :query argument differently than expected.

    Here's a very simple example to test using cURL at the command line. If the plan isn't "free", you'll need the rest of the subscription data.

    curl -u yourusername:yourpassword -d 'code=whatever&firstName=Example&lastName=Customer&email=[email blocked]&subscription[planCode]=FREE_PLAN_CODE' https://cheddargetter.com/xml/customers/new/productCode/YOUR_PRODUCT_CODE
    
  7. 5 Posted by Jon Larkowski on 25 Aug, 2009 12:38 PM

    Jon Larkowski's Avatar

    Turns out that using the :body key instead of the :query key when calling Request.post solves this.

  8. Support Staff 6 Posted by Marc Guyer on 25 Aug, 2009 01:51 PM

    Marc Guyer's Avatar

    I guess my rudimentary tests never sent a post. Hmm... Thanks for
    troubleshooting that.

  9. Marcela Poffald closed this discussion on 11 Apr, 2018 06:02 PM.

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

Keyboard shortcuts

Generic

? 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