Skip to main content
deleted 4 characters in body
Source Link
rpm07
  • 511
  • 6
  • 18

This would be a duplicate, but I really need the a good solution. I have tried to research but failed to find anything. Not to complicate, I know it is easy if I just used a GET method, but I needed to use DELETE method. Using DELETE would be easy for the api that I'm sending the request to directly call its Delete method.

I know I should not set the Body but, how I'am able to send the id to the api?

Code Snippet:

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

req.setEndpoint('testsite.com/api/User'); 
req.setMethod('DELETE'); 
req.setBody('29'); 
req.setHeader('Content-Type', 'application/json'); 

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

System.debug(res.getBody());

This would be a duplicate, but I really need the a good solution. I have tried to research but failed to find anything. Not to complicate, I know it is easy if I just used a GET method, but I needed to use DELETE method. Using DELETE would be easy for the api that I'm sending the request to directly call its Delete method.

I know I should not set the Body but, how I'am able to send the id to the api?

Code Snippet:

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

req.setEndpoint('testsite.com/api/User'); 
req.setMethod('DELETE'); 
req.setBody('29'); 
req.setHeader('Content-Type', 'application/json'); 

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

System.debug(res.getBody());

This would be a duplicate, but I really need a good solution. I have tried to research but failed to find anything. Not to complicate, I know it is easy if I just used a GET method, but I needed to use DELETE method. Using DELETE would be easy for the api that I'm sending the request to directly call its Delete method.

I know I should not set the Body but, how I'am able to send the id to the api?

Code Snippet:

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

req.setEndpoint('testsite.com/api/User'); 
req.setMethod('DELETE'); 
req.setBody('29'); 
req.setHeader('Content-Type', 'application/json'); 

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

System.debug(res.getBody());
Source Link
rpm07
  • 511
  • 6
  • 18

How to fix HTTP method DELETE doesn't support output

This would be a duplicate, but I really need the a good solution. I have tried to research but failed to find anything. Not to complicate, I know it is easy if I just used a GET method, but I needed to use DELETE method. Using DELETE would be easy for the api that I'm sending the request to directly call its Delete method.

I know I should not set the Body but, how I'am able to send the id to the api?

Code Snippet:

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

req.setEndpoint('testsite.com/api/User'); 
req.setMethod('DELETE'); 
req.setBody('29'); 
req.setHeader('Content-Type', 'application/json'); 

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

System.debug(res.getBody());