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
Ramadhar MishraRamadhar Mishra 

System.HttpResponse[Status=Unsupported Media Type , Status Code=415]

Hi All,

 

i have following apex class. when calling through apex trigger getting following error.

 

System.HttpResponse[Status=Unsupported Media Type, StatusCode=415]

 

Can any one suggest what the mistake im doing in below code.

 

global class CaseRestService2{
@future (callout=true)
global static void sendChangeOwnerid(){

HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();

req.setEndpoint('http://dev1sfdc.caremark.com/BenefitBuilderWeb/Notification?wsdl');

req.setMethod('POST');
String name ='Rahul';
String City='Delhi';

req.setHeader('content-type', 'text/html');
//req.setHeader('Accept', 'application/xml');
req.setHeader('Content-Length','1024');
req.setHeader('Host','dev1sfdc.caremark.com');


req.setBody('name='+EncodingUtil.urlEncode(name, 'UTF-8')+'&city='+EncodingUtil.urlEncode(city, 'UTF-8'));
req.setCompressed(true); // otherwise we hit a limit of 32000

try {
res = http.send(req);
} catch(System.CalloutException e) {
System.debug('Callout error: '+ e);
System.debug(res.toString());
}
// System.debug(res.getBody());
}
}