You need to sign in to do that
Don't have an account?
Alex Makk
How do I make a proper HTTP request?
Hello, I'm trying to follow API instructions and I'm stuck at the very beginning. Here is what it says:
Following the example, POST the username and password fields with your email and password, along with the grant_type value of password, to the https://api.safetyculture.io/auth endpoint.
In debug logs I get:
13:17:54:754 CALLOUT_RESPONSE [15]|System.HttpResponse[Status=Bad Request, StatusCode=400]
Please advise. Thank you!
Following the example, POST the username and password fields with your email and password, along with the grant_type value of password, to the https://api.safetyculture.io/auth endpoint.
curl \ -X POST \ --data-urlencode username=example@safetyculture.io \ --data-urlencode password=your_password \ -d grant_type=password \ "https://api.safetyculture.io/auth"Here is what I do:
String username = 'some.email@domain.com'; String password = 'apple'; HttpRequest req = new HttpRequest(); req.setEndpoint('https://api.safetyculture.io/auth'); req.setMethod('POST'); req.setbody('username='+username+'&password='+password+'&grant_type=password'); Http http = new Http(); HTTPResponse response = http.send(req);
In debug logs I get:
13:17:54:754 CALLOUT_RESPONSE [15]|System.HttpResponse[Status=Bad Request, StatusCode=400]
Please advise. Thank you!
Have you checked the relevant posts https://salesforce.stackexchange.com/questions/163256/rest-api-to-authenticate-with-basic-username-and-password
https://salesforce.stackexchange.com/questions/251911/which-grant-type-to-use-when-third-party-is-accessing-salesforce
Thanks