function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex MakkAlex 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 endpoint.
curl \
  -X POST \
  --data-urlencode \
  --data-urlencode password=your_password \
  -d grant_type=password \
Here is what I do:
String username = '';
String password = 'apple';

HttpRequest req = new HttpRequest();

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!
SwethaSwetha (Salesforce Developers) 
HI Alex,
Have you checked the relevant posts