C# 邮递API不起作用
我正在使用过去一年的邮递报价API,当我检查时,它运行良好 但现在它似乎不起作用了 它抛出了一个带有一些启用cookie和验证码的HTML文本的异常 我不明白我是否错过了一些邮递更新 这是我的代码C# 邮递API不起作用,c#,postmates,C#,Postmates,我正在使用过去一年的邮递报价API,当我检查时,它运行良好 但现在它似乎不起作用了 它抛出了一个带有一些启用cookie和验证码的HTML文本的异常 我不明白我是否错过了一些邮递更新 这是我的代码 HttpWebRequest req = WebRequest.Create(new Uri("https://api.postmates.com/v1/customers/" + PostmatesCustomerId + "/delivery_quotes")) as HttpWebRequest
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();
}
若您不在美国,请尝试使用VPN作为测试的变通方法