0

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:

@RestResource(urlMapping='/QLIDelete/*')
global with sharing class RESTQLIDelCon {
@HttpDelete
  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];

    if(!DelQLI.isEmpty()){
    delete DelQLI;
    return 'Quote Line Items are deleted';
    }
    else{
    return 'Quote Line Items are not deleted due to some issues';
    }
  }
}
1
  • The below is the URL, I tried from Workbench: /services/apexrest/QLIDelete?id=0Q0n0000000XY61ABC Commented Feb 20, 2018 at 0:05

1 Answer 1

2

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .