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
Firoz MirzaFiroz Mirza 

A trivial mistake in Trailhead module

A trivial (but helpful, I admit) error in the module 'Apex Integration Services' -> Apex Web Services,  in the @HttpPut method - 
https://trailhead.salesforce.com/modules/apex_integration_services/units/apex_integration_webservices
An additional line of code (thisCase.id = id;) is missing before the 'upsert'  statement in the following practice code of this trailhead section. Request to please correct this if judged appropriate. btw, this mistake was helpful to me during learning....so up to you.

@HttpPut
global static ID upsertCase(String subject, String status,
    String origin, String priority, String id) {
    Case thisCase = new Case(
        Id=id,
        Subject=subject,
        Status=status,
        Origin=origin,
        Priority=priority);
    // Match case by Id, if present.
    // Otherwise, create new case.
    upsert thisCase;
    // Return the case ID.
    return thisCase.Id;
}
 
Best Answer chosen by Firoz Mirza
Amit Chaudhary 8Amit Chaudhary 8
No need to that as below line is in code

  Case thisCase = new Case(
        Id=id,
        Subject=subject,
        Status=status,
        Origin=origin,
        Priority=priority);

All Answers

Amit Chaudhary 8Amit Chaudhary 8
No need to that as below line is in code

  Case thisCase = new Case(
        Id=id,
        Subject=subject,
        Status=status,
        Origin=origin,
        Priority=priority);
This was selected as the best answer
Firoz MirzaFiroz Mirza
Thanks, Amit... You're absolutely correct...
Actually, my code had a stupid error and I had missed this crucial parameter.
warm regards