You need to sign in to do that
Don't have an account?
Eric Blaxton 11
APEX callout POST for authorization key error
Hi and thanks in advance.
I am trying to get an access key and keep getting the "unsupported grant type" error.
I've verified I can access the url via Postman
Apex class:
Eric
I am trying to get an access key and keep getting the "unsupported grant type" error.
I've verified I can access the url via Postman
Apex class:
public class ApiBearerKey { public static String getBearerKey() { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint('https://fakeaddress/token'); request.setMethod('POST'); request.setHeader('Content-Type', 'application/json;charset=UTF-8'); request.setHeader('username','xxx'); request.setHeader('password','xxx'); request.setHeader('grant_type','password'); request.setBody(''); HttpResponse response = http.send(request); System.debug('Response : '+response.getBody()); System.debug('UserInfo : '+UserInfo.getSessionID()); return null; } }Appreciate the help.
Eric
All Answers
Greetings!
Usually the error occurs when the endpoint is incorrect.I would suggest you to double check the Endpoint which is being used
If it is Sandbox,make sure to use test.salesforce.com or use the valid domain name.
Reference:https://salesforce.stackexchange.com/questions/172980/errorunsupported-grant-type-error-descriptiongrant-type-not-supported
Also,try by logging into the org using the Username and Password to make sure the credentials are valid with the endpoint.
Kindly mark it as best answer if it helps so that it can help others in the future.
Warm Regards,
Shirisha Pathuri
Hello,
have you tried setting the Content type to x-www-form-urlencoded?
I tried that to no avail. I have verified the endpoint in Postman.
Regards,
Eric