我正在尝试将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"
]
}
]
}
]
}
不确定我可能会丢失什么!
可能浏览器的cookie可能会影响您的结果。因此,可能是您选择不同答案的原因。