I know I am a horrible coder. I tried below code snippet for REST Delete. But the Rest context returning me a null instead of Id even though I passed an Id from Workbench Rest explorer. Here is my code:

global with sharing class RESTQLIDelCon {
  global static String deleteQLI() {
    Id QuoteId = RestContext.request.params.get('Id');
    //System.debug('RestContext.request.params'+ RestContext);
    System.debug('Id======>' + QuoteId);
    Quote DelQuote = [ Select ID from Quote where Id = :QuoteId];

    List<QuoteLineItem> DelQLI= [SELECT Id, LineNumber from QuoteLineItem WHERE QuoteId =: DelQuote.Id];

    delete DelQLI;
    return 'Quote Line Items are deleted';
    return 'Quote Line Items are not deleted due to some issues';
  • The below is the URL, I tried from Workbench: /services/apexrest/QLIDelete?id=0Q0n0000000XY61ABC – chaitanyababu e Feb 20 '18 at 0:05

Apex maps are case sensitive. You are requesting the key 'Id', but the URL provides the parameter 'id'. That's why you're obtaining a null value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.