Problem in Creation a New Customer

uzair's Avatar

uzair

03 Jul, 2012 02:57 PM

Hi there

I have created a test account to test CheddarGetter API. We also have a running Application on CheddarGetter and it is working fine. Now I am trying to setup another account and created a test account for new one.

In the new account I want to create a customer. I am using a third party C# library available on GitHub for CheddarGetter API. When I try to post a request to add a new customer I caught this Error "The remote server returned an error: (404) Not Found."

I think this is not a wrong URL Error because if I did not provide any of required parameter CheddarGetter API returns "precondition failed error" and this error is logged automatically on server where I can see it for troubleshooting.

Now I removed the third party wrapper and try to make a request but the error is still exist and no result is returned. Here is my code;-

                string urlBase = "https://cheddargetter.com/xml";
                string _ProductCode = "TESTVALUELINK";
                string urlPath =  string.Format("/customers/new/productCode/{0}", _ProductCode);
                string initialBillingDate = newCustomer.initialBillDate.Year.ToString() + "-" + DateTime.Now.Month.ToString("d2") + "-" + newCustomer.initialBillDate.Day.ToString();
                string postParams = string.Format(
                    "code={0}" +
                    "&firstName={1}" +
                    "&lastName={2}" +
                    "&email={3}" +
                    "&company={4}" +
                    "&subscription[planCode]={5}" +
                    "&subscription[ccFirstName]={6}" +
                    "&subscription[ccLastName]={7}" +
                    //"&subscription[ccNumber]={8}" +
                    //"&subscription[ccExpiration]={9}" +
                    //"&subscription[ccCardCode]={10}" +
                    //"&subscription[ccAddress]={11}" +
                    //"&subscription[ccCity]={12}" +
                    //"&subscription[ccState]={13}" +
                    //"&subscription[initialBillDate]={14}" +
                    //"&subscription[ccZip]={15}",
                    "&subscription[method]={8}",
                    "&subscription[returnUrl]={9}",
                    "&subscription[cancelUrl]={10}",
                    HttpUtility.UrlEncode(newCustomer.Code),
                    HttpUtility.UrlEncode(newCustomer.FirstName),
                    HttpUtility.UrlEncode(newCustomer.LastName),

                    HttpUtility.UrlEncode(newCustomer.Email),
                    HttpUtility.UrlEncode(newCustomer.Company),
                    HttpUtility.UrlEncode(newCustomer.PlanCode.ToString().ToUpper()),

                    HttpUtility.UrlEncode(newCustomer.CCFirstName),
                    HttpUtility.UrlEncode(newCustomer.CCLastName),
                    //HttpUtility.UrlEncode(newCustomer.CCNumber),

                    //HttpUtility.UrlEncode(newCustomer.CCExpiration),
                    //HttpUtility.UrlEncode(newCustomer.CCCardCode),
                    //HttpUtility.UrlEncode(newCustomer.CCAddress),

                    //HttpUtility.UrlEncode(newCustomer.CCCity),
                    //HttpUtility.UrlEncode(newCustomer.CCState),
                    //HttpUtility.UrlEncode(newCustomer.initialBillDate.ToString("s")),

                    //HttpUtility.UrlEncode(newCustomer.CCZip),

                    HttpUtility.UrlEncode("paypal"),
                    HttpUtility.UrlEncode("http://mywebapp.com/login?paypalAccepted"),
                    HttpUtility.UrlEncode("http://mywebapp.com/login?paypalCanceled")

                    );


                string mainURL = urlBase + urlPath;
                HttpWebRequest request = WebRequest.Create(mainURL) as HttpWebRequest;
                string _Username = ConfigurationManager.AppSettings["CheddarGetterUser"];
                string _Password = ConfigurationManager.AppSettings["CheddarGetterPassword"];
                //Add authentication
                request.Credentials = new NetworkCredential(_Username, _Password);

                //make into a post
                request.ContentType = "application/x-www-form-urlencoded";
                request.Method = "POST";
                //request.Proxy.IsBypassed(new Uri(mainURL));


                byte[] bytes = Encoding.UTF8.GetBytes(postParams);
                request.ContentLength = bytes.Length;


                string result = "";
                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(bytes, 0, bytes.Length);

                    using (WebResponse response = request.GetResponse())
                    {
                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            result = reader.ReadToEnd();
                        }
                    }
                }
  1. Support Staff 1 Posted by Marc Guyer on 04 Jul, 2012 02:05 PM

    Marc Guyer's Avatar

    Hi Uzair -- It appears that you've created a few customers today. Are you still having this problem?

  2. Marc Guyer closed this discussion on 31 Jul, 2012 12:46 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