Search code examples
c#postmates

Postmates API not working


I am using postmates Delivery Quote API for the last one year, And it is working good by the time when I checked.

But now it seems to be not working

It is throwing an exception with an HTML text with some enable cookies and captcha

I can't understand if i am missing some updates from postmates

Here is my coding

HttpWebRequest req = WebRequest.Create(new Uri("https://api.postmates.com/v1/customers/" + PostmatesCustomerId + "/delivery_quotes")) as HttpWebRequest;

            req.Method = "POST";
            req.ContentType = "application/x-www-form-urlencoded";
            req.Headers.Add("Authorization", "Basic " + Base64string);             

            StringBuilder paramz = new StringBuilder();
            paramz.Append("pickup_address=" + PickUpAddress + "&dropoff_address=" + DeliveryAddress);

            byte[] formData =
                UTF8Encoding.UTF8.GetBytes(paramz.ToString());
            req.ContentLength = formData.Length;

            // Send the request:
            using (Stream post = req.GetRequestStream())
            {
                post.Write(formData, 0, formData.Length);
            }
            string responseString = null;
            using (HttpWebResponse resp = req.GetResponse()
                                          as HttpWebResponse)
            {
                StreamReader reader =
                    new StreamReader(resp.GetResponseStream());
                responseString = reader.ReadToEnd();
            }

Solution

  • If you're outside of the US, try using a VPN as a workaround to test.