You need to sign in to do that
Don't have an account?

"POST requires content-length error" occur when i am trying to call custom Rest API @HttpDelete Resource ..
HttpRequest req1=new HttpRequest();
req1.setMethod('POST');
req1.setEndpoint('https://ap1.salesforce.com/services/apexrest/MyPackageAC/ServerRestApi/0019000001N7LjKAAV?_HttpMethod=DELETE');
req1.setHeader('Authorization','OAuth '+access_token);
HttpResponse res=p1.send(req1);
system.debug(res);
result=res.getBody();
=============================================================================
@RestResource(urlMapping='/ServerRestApi/*')
global class ServerResource
{
@HttpDelete
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
delete account;
}
}
what could be reason for this error "POST requires content-length error".
req1.setMethod('POST');
req1.setEndpoint('https://ap1.salesforce.com/services/apexrest/MyPackageAC/ServerRestApi/0019000001N7LjKAAV?_HttpMethod=DELETE');
req1.setHeader('Authorization','OAuth '+access_token);
HttpResponse res=p1.send(req1);
system.debug(res);
result=res.getBody();
=============================================================================
@RestResource(urlMapping='/ServerRestApi/*')
global class ServerResource
{
@HttpDelete
global static void doDelete() {
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String accountId=req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
Account account = [SELECT Id FROM Account WHERE Id = :accountId];
delete account;
}
}
what could be reason for this error "POST requires content-length error".
Account account=[select id From Account];