我已经为 Shopify 网站设置了 API 密钥,并且能够使用以下代码执行 GET 请求请求
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet get = new HttpGet("https://75da...:2a1dd3...@mytest.myshopify.com/admin/products.json");
response = httpClient.execute(get);
以上是在 junit 测试中使用 Apache httpcomponents client 4.2.3 和 httpcomponents core 4.2.4
使用相同的参数,我尝试使用 WS.url() 但我得到的响应为 401 - Unauthorized with message in body
[API] API 密钥或访问令牌无效(无法识别登录或密码错误)
我在junit测试中使用的代码:
WSRequestHolder requestHolder = WS.url("https://75da...:2a1dd3...@mytest.myshopify.com/admin/products.json");
Promise<Response> promise = requestHolder.get();
Response response = promise.get();
我正在使用播放 2.1.3。
所以区别在于使用 apache 与 WS,我认为 WS 需要一些配置。有人可以提供一些见解吗?
谢谢