public class Rg_TestMemberAccountCreate {
public static void testMemberAccount(String endpoint,String token){
Http http = new Http();
HttpRequest request = new HttpRequest();
request.setEndpoint(endpoint);
request.setMethod('POST');
request.setHeader('Content-Type', 'application/json');
request.setHeader('Authorization', 'Bearer '+token);
request.setHeader('Accept', 'application/json');
// Set the body as a JSON object
String b = '{"data": {"attributes": {"name": "Test Rahul2","symbol": "TESTRT", "is_active": "true"},"type": "providers"}}';
request.setBody(b);
System.debug('Requst : '+request);
HttpResponse response = http.send(request);
System.debug('response: '+response);
// Parse the JSON response
if (response.getStatusCode() != 200) {
System.debug('The status code returned was not expected: ' + response.getStatusCode() + ' ' + response.getStatus());
} else {
System.debug(response.getBody());
}
}
}
do you have any idea what is wrong in my class?
Thank You,RahulFound the issue after trying 5 hrs,there are some required fields that need to be sent in body after adding that issus is solvedThanks, Swetha ,now its working