Hello Guys,
I have installed SuiteCRM on my local machine (WAMP Environment) and I am trying to call the V8 REST API for access token through JAVA; but it always throws a 301 Moved Permanently status on the response and I am unable to get the token. I also tried calling this with the demo setup but it still results in the same. I have searched a lot through the forums and tried multiple approaches but to vain!
These are the URL I am trying to hit :
https://demo.suiteondemand.com/index.php/api/oauth/access_token (on demo) - gives 301 response
http://localhost/SuiteCRM-7.10.2/index.php/api/oauth/access_token (on local) - same response
Here is the code in Java that I am executing:
URI url = new URI(“https://demo.suiteondemand.com/index.php/api/oauth/access_token”);
RestTemplate template = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.add("Content-Type", "application/vnd.api+json");
headers.add("Accept", "application/vnd.api+json");
HashMap<String, String> auth_data = new HashMap<>();
auth_data.put("grant_type", "client_credentials");
auth_data.put("client_id","3D7f3fda97-d8e2-b9ad-eb89-5a2fe9b07650");
auth_data.put("client_secret", "adasdasdasd");
auth_data.put("scope", "standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete");
HttpEntity<HashMap<String, String>> httpEntity = buildRequest(auth_data,headers);
ResponseEntity<String> responseEntity = template.exchange(url, HttpMethod.POST,httpEntity, String.class);
responseEntity.getBody();
System.out.println(responseEntity.getStatusCodeValue());
I suppose there is some issue with the URL and I would really appreciate if I get some insights on getting the access token with my local setup through REST APIs. Thanks in advance.