SuiteCRM V8 APIs not responding with local setup

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.

If your SuiteCRM version is really 7.10.2, please upgrade to 7.10.4 before anything else. There have been API fixes in every recent release.

Thanks for the reply!
I was able to hit the API for access token successfully after configuring the .htaccess file!

But now I am getting a 400 Bad Request every time. I did go in and create a client_credentials client for my user, still giving 400 Bad request.
Here are the details:

URL : http://localhost/SuiteCRM-7.10.4/api/oauth/access_token

Request:

{
	"grant_type":"client_credentials",
	"client_id":"c52exxxxxxxxxxxxxxxb0f71",
	"client_secret":"xxxxx",
	"scope":"standard:create standard:read standard:update standard:delete standard:delete standard:relationship:create standard:relationship:read standard:relationship:update standard:relationship:delete"
}

Response:

"code": 8000,
"title": "[SuiteCRM] [API] [OAuth] Unable to generate private key",
"status": 400

Thanks in advance and appreciate a solution.

Hey, do you can fix this error, i’m stoped here…

Hi, for a solution, look here:
https://suitecrm.com/suitecrm/forum/developer-help/21354-suitecrm-api-oauth-unable-to-generate-private-key#76029