【发布时间】:2020-06-21 20:03:28
【问题描述】:
我正在尝试使用 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"
]
}
]
}
]
}
不知道我可能会错过什么!
【问题讨论】:
标签: java spring spring-boot ebay-api