Bhadresh Shiroya
Bhadresh Shiroya

Reputation: 261

HTTP Status 500 - Request processing failed; nested exception is org.springframework.web.client.HttpClientErrorException: 403 null type

We are trying to send GET or POST request using a resttemplate spring lib

Look like error Live Server throw error Local envirment working very well

enter image description here

Upvotes: 0

Views: 638

Answers (1)

Sai prateek
Sai prateek

Reputation: 11906

I think you should add a "User-Agent" header to your request. You can either try to set a custom user agent value or use some value that identifies a browser.

Like-

RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
headers.add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36");
HttpEntity<String> entity = new HttpEntity<String>("parameters", headers);

Object response = restTemplate.exchange("https://test.prateek.com/tests.json", HttpMethod.GET,entity,Object.class);

Upvotes: 1

Related Questions