LogicLuminaryy / Solution-Apex-Callouts-Superbadge-Unit-

Apex Callouts Superbadge Unit
4 stars 1 forks source link

Issue with completing challenge 1 #3

Closed calmeeee closed 3 months ago

calmeeee commented 3 months ago

Can't resolve the first challenge with request to Balanced Living API. After investigating org's setup, I've found that Trailhead pre-installed a package with named credentials BalancedLiving as well as external named credentials BalancedLivingCredential. The authorization mechanism for this challenge is much similar to the one from challenge 3 - there is a custom header with Authorization name and {!'Basic ' & BASE64ENCODE(BLOB($Credential.BalancedLivingCredential.Username & ':' & $Credential.BalancedLivingCredential.Password))} formula value. But there is nowhere to actually take both these values. The only principal with DevAccess name which is created by them contains no such parameters. I guess it's the one which is used in authorization since it's assigned to you through permission set. The errors I receive while trying different solutions are expected.

  1. When I'm just setting up req.setEndpoint('callout:IntegrationSB__BalancedLiving/rewards'); in the code it tells me System.CalloutException: Field BalancedLivingCredential.Username does not exist. Check spelling.
  2. If I add Username/Password parameters to existing Principal by myself (e.g. my own login/password from the org) then the service returns { "error": "Authentication Attempt Failed" }.

The trailhead support answered me that "org is fine, just follow the instructions and check configuration article". Maybe I'm missing something in setup but can't find it? Everything was done by their instructions