When I run my App, I'm getting a HttpClientErrorException: 400 Bad Request for the following line of code.
Wine sw = mRestApi.getWine( "48854" );
The error message isn't very helpful, so I'm hoping someone can point me in the right direction.
The getWine method generated by AA is:
@Override
public WineCom getWine(String id) {
HashMap<String, Object> urlVariables = new HashMap<String, Object>();
urlVariables.put("id", id);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
HttpEntity<Object> requestEntity = new HttpEntity<Object>(httpHeaders);
return restTemplate.exchange(rootUrl.concat("
http://services.com/catalog?filter=product({id})"), HttpMethod.GET, requestEntity, Wine.class, urlVariables).getBody();
}
My Wine class is the following:
public class Wine {
private String id;
private String name;
private String url;
private String appelationId;
private String appelationName;
private String regionId;
private String regionName;
private String drinkType;
private String varietalId;
private String varietalName;
}
I'm wondering if the mapping might be failing because my POJO doesn't contain all the data returned? Or it might be something else entirely...
Running curl, produces the following result:
vinotheque(1.1) $ curl -v "
http://services.com/catalog?filter=product(48854)"
* About to connect() to
services.com port 80 (#0)
* Trying 208.36.10.133... connected
* Connected to
services.wine.com (208.36.10.133) port 80 (#0)
> GET /catalog?filter=product(48854) HTTP/1.1
> User-Agent: curl/7.21.3 (i686-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/
1.2.3.4 libidn/1.18
> Host:
services.com> Accept: */*
>
< HTTP/1.1 200 OK
< Date: Fri, 06 Jul 2012 17:34:25 GMT
< Server: Microsoft-IIS/6.0
< X-Powered-By:
ASP.NET< X-AspNet-Version: 4.0.30319
< Content-Length: 1655
< Cache-Control: private
< Content-Type: application/json; charset=utf-8
<
{"Status":{"Messages":[],"ReturnCode":0},"Products":{"List":[{"Id":48854,"Name":"Barton & Guestier Merlot 2000","Url":"http:\/\/
www.wine.com\/V6\/Barton-and-Guestier-Merlot-2000\/wine\/48854\/detail.aspx","Appellation":{"Id":2374,"Name":"Languedoc-Roussillon","Url":"http:\/\/
www.wine.com\/v6\/Languedoc-Roussillon\/wine\/list.aspx?N=7155+102+2374","Region":{"Id":102,"Name":"France - Other regions","Url":"http:\/\/
www.wine.com\/v6\/France-Other-regions\/wine\/list.aspx?N=7155+102","Area":null}},"Labels":[{"Id":"48854m","Name":"thumbnail","Url":"http:\/\/
cache.wine.com\/labels\/48854m.jpg"},{"Id":"48854l","Name":"large","Url":"http:\/\/
cache.wine.com\/labels\/48854l.jpg"}],"Type":"Wine","Varietal":{"Id":138,"Name":"Merlot","Url":"http:\/\/
www.wine.com\/v6\/Merlot\/wine\/list.aspx?N=7155+124+138","WineType":{"Id":124,"Name":"Red Wines","Url":"http:\/\/
www.wine.com\/v6\/Red-Wines\/wine\/list.aspx?N=7155+124"}},"Vineyard":{"Id":5708,"Name":"Barton & Guestier","Url":"http:\/\/
www.wine.com\/v6\/Barton-and-Guestier\/l* Connection #0 to host
services.wine.com left intact
* Closing connection #0
earnabout.aspx?winery=1693","ImageUrl":"","GeoLocation":{"Latitude":-360,"Longitude":-360,"Url":""}},"Vintage":"","Community":{"Reviews":{"HighestScore":0,"List":[],"Url":"http:\/\/
www.wine.com\/V6\/Barton-and-Guestier-Merlot-2000\/wine\/48854\/detail.aspx?pageType=reviews"},"Url":"http:\/\/
www.wine.com\/V6\/Barton-and-Guestier-Merlot-2000\/wine\/48854\/detail.aspx"},"Description":"","GeoLocation":{"Latitude":-360,"Longitude":-360,"Url":""},"PriceMax":10.9900,"PriceMin":7.9900,"PriceRetail":0,"ProductAttributes":[],"Ratings":{"HighestScore":89,"List":[]},"Retail":null,"Vintages":{"List":[]}}],"Offset":0,"Total":1,"Url":""}}