This question runs in a pre-configured Salesforce environment - no personal connection required.

Make an HTTP callout to the Star Wars API to fetch character details by ID. Return a Map containing the character name, height, and mass. If the API call fails, returns an error status code, or the characterId is invalid, return null.

The Star Wars API endpoint is: https://swapi.info/api/people/{id}

The API returns a JSON response with character details including name, height, mass, and other properties. Extract only the name, height, and mass fields and return them in a Map with keys: 'name', 'height', 'mass'.

Examples:

Input: characterId = 1 Output: {'name' => 'Luke Skywalker', 'height' => '172', 'mass' => '77'} Explanation: Fetches character with ID 1 and returns name, height, and mass Input: characterId = 4 Output: {'name' => 'Darth Vader', 'height' => '202', 'mass' => '136'} Explanation: Fetches character with ID 4 and returns name, height, and mass Input: characterId = 999 Output: null Explanation: Invalid character ID returns null
Apex Code Editor

Welcome to Lightning Challenge!

How It Works

  • • Write your solution in the code editor
  • • This challenge runs without connecting your own org
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Contest Alert

🏆 #CodeEveryDay July 2026

Contest runs July 1 - 31. Complete challenges to climb the leaderboard!

Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In