繁体   English   中英

Spring Boot 获取 Api 响应:Ebay API

[英]Spring Boot Get Api Response: Ebay API

我正在尝试使用 Ebay API 进行测试,但看起来我没有得到我想要达到的结果。

我的控制器中有这个@GetMapping请求:

 @GetMapping(value = "test")
    public ResponseEntity testLogin(){

        RestTemplate restTemplate = new RestTemplate();

        String findCompletedItemsUrl =  "https://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=THIS-IS-MY-APP-ID&OPERATION-NAME=findCompletedItems&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&keywords=iphone%20case&categoryId=9355&sortOrder=PricePlusShippingLowest&itemFilter(0).name=Condition&itemFilter(0).value=1000&itemFilter(1).name=SoldItemsOnly&itemFilter(1).value=true&paginationInput.entriesPerPage=10&outputSelector(0)=SellerInfo&GLOBAL-ID=EBAY-US";

        ResponseEntity<String> response = restTemplate.getForEntity(findCompletedItemsUrl, 
         String.class);
        return response;

    }

请注意 URL 有一个 APP ID 占位符。 当我通过浏览器访问 URL 时,我得到以下结果:

{
  "findCompletedItemsResponse": [
    {
      "ack": [
        "Success"
      ],
      "version": [
        "1.13.0"
      ],
      "timestamp": [
        "2020-03-09T21:54:58.595Z"
      ],
      "searchResult": [
        {
          "@count": "1",
          "item": [
            {
              "itemId": [
                "174129065971"
              ],
              "title": [
                "For Apple iPhone 8 Plus Case Shock Absorption Cover Shockproof Bumper Rose"
              ],

       ...cut for brevity
        }
       ]
     }

但是当我尝试使用上述方法访问相同的 URL 时,我没有得到任何结果并且 count 属性显示为 0。我返回的 json 如下:

{
  "findCompletedItemsResponse": [
    {
      "ack": [
        "Success"
      ],
      "version": [
        "1.13.0"
      ],
      "timestamp": [
        "2020-03-09T21:57:05.206Z"
      ],
      "searchResult": [
        {
          "@count": "0"
        }
      ],
      "paginationOutput": [
        {
          "pageNumber": [
            "0"
          ],
          "entriesPerPage": [
            "10"
          ],
          "totalPages": [
            "0"
          ],
          "totalEntries": [
            "0"
          ]
        }
      ]
    }
  ]
}

不知道我可能会错过什么!

浏览器的cookies可能会影响您的结果。 所以这可能是你不同答案的原因。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM