我在过去的一年里一直在使用postmates Quote API,当我检查的时候,它工作得很好。
但是现在它似乎不起作用了。
它抛出了一个包含一些启用cookie和验证码的HTML文本的异常
我不明白我是不是错过了postmates的一些更新
下面是我的代码
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();
}发布于 2017-03-01 06:21:03
如果您不在美国,可以尝试使用VPN作为测试的变通方法。
https://stackoverflow.com/questions/42502638
复制相似问题