Spring RestTemplate throws 404 but curl and browser call works

Viewed 918

RestTemplate Code :

    final HttpEntity<String> entity = new HttpEntity<String>(headers);      

    ResponseEntity<String> quote = restTemplate.exchange(
            "http://localhost:8080/groups/HOLDEN_REGION",HttpMethod.GET, entity , String.class);

Controller Code :

@RestController public class GroupController {

@RequestMapping(value="/groups/{groupTypeName}", method= RequestMethod.GET)
public Set<Group> getGroups(@ApiParam(value = "groupTypeName", required = true) @PathVariable("groupTypeName") String groupTypeName) {
    return groupService.getGroupsForGroupTypeName(groupTypeName);
}

}

When i hit the same url using curl and browser , its working with no issues. But when i use spring resttemplate, i am getting 404 error . I have tried to set the headers and all, but still no luck. Any help would be greatly appreciated.

0 Answers
Related