1

I'm currently trying to make a PUT call to my Gemfire Cache test enviroment https://gemfire.docs.pivotal.io/95/geode/rest_apps/put_update_data.html

I've tried following a template like so

 RestTemplate restTemplate = new RestTemplate();
    String url = "http://localhost:8080/spring-rest/data/putdata/{id}/{name}";
    Map<String, String> map = new HashMap<String, String>();
    map.put("id", "100");
    map.put("name", "Ram");
    Address address = new Address("Dhananjaypur", "Varanasi","UP");
    restTemplate.put(url, address, map);
}

Where in my case would it look something like this?

 RestTemplate restTemplate = new RestTemplate();
    String url = "gemfire.com/gemfire-api/v1/{region}/{key};
    Map<String, String> map = new HashMap<String, String>();
    map.put("region", "1");
    map.put("key", "testKey");
    restTemplate.put(url, "testStringtoPut", map);
}

This template leads into a 404 not found error for me, can someone provide an insight on a proper method of doing this?

Matthias
  • 4,481
  • 12
  • 45
  • 84
Hiya54 Huy
  • 37
  • 10
  • is your application running in port 8080? If so check the endpoints and configuration of the `spring-rest` app – Arun Aug 14 '18 at 19:18

1 Answers1

0

Try doing it this way, it should work

HttpEntity<String> request = new HttpEntity<String>(address.toString());

String url=http://localhost:8080/spring-rest/data/putdata/100/"Ram"

ResponseEntity <String> response= template.exchange(url,HttpMethod.PUT,request,String.class);
Tschallacka
  • 27,901
  • 14
  • 88
  • 133
Jay
  • 132
  • 1
  • 4
  • still 404, but also i believe it only takes in JSON to PUT, gemfire doesnt accept other formats – Hiya54 Huy Aug 14 '18 at 20:02
  • you can add content type in headers. HttpHeaders=new Httpheaders(); headers.setContentType(MediaType.APPLICATION_JSON); and now HttpEntity request = new HttpEntity(address.toString(), headers); This way you are only sending JSON Data. – Jay Aug 14 '18 at 20:10
  • also check the url again – Jay Aug 14 '18 at 20:18
  • added content type headers, but now im getting 405 method not allowed – Hiya54 Huy Aug 14 '18 at 20:19
  • https://www.1and1.com/digitalguide/hosting/technical-matters/error-405-method-not-allowed-explanation-and-solutions/ . 405 may have many causes. Please go through the link. – Jay Aug 14 '18 at 20:28
  • you are hitting the desired url. gemfire may not be letting you in due to security reasons. – Jay Aug 14 '18 at 20:31
  • yeah its not letting me in but i disabled certificate validation to test, bad solution but it's letting me access it. I think my error was bad JSON format, will continue giving it a try – Hiya54 Huy Aug 14 '18 at 20:33