【发布时间】:2016-03-14 17:04:31
【问题描述】:
我正在使用适用于浏览器但不适用于 API 调用的 shopify Private 应用 API URL。我收到{"The remote server returned an error: (401) Unauthorized."}
using (var client = new WebClient())
{
var values = new NameValueCollection();
var since = DateTime.Now.AddDays(-30).ToString("yyyy-MM-dd HH:mm");
client.Headers.Add(values);
var response = client.DownloadString(string.Format("https://xxxx:xxxxx@abc.myshopify.com/admin/orders.json"));
orders = JsonConvert.DeserializeObject<ShopifyApiObjects.SalesOrders>(response);
}
如果有人有想法,请提供帮助。提前致谢。
【问题讨论】:
-
该 API 的身份验证方案是什么样的?您很可能需要传入密钥(如果它使用 OAuth)或实际凭据。
-
在 shopify 中,我们在 URL 中有 API 密钥和密码,所以我认为不需要身份验证
-
尝试通过标头数据而不是 url 传递 apikey 和 api_password。