• Knowledge lover
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 2
    Replies
I tried to complete the badge API basics and got stuck at #Use SOAP API
 
I got the error: Challenge Not yet complete... here's what's wrong:  It doesn't appear that you have logged in using SoapUI.

I have verified I connected to the right org.  Could someone help here? 
as to finish the trailhead module "Trailhead API", I was stuck at part 6 "Search Using the Trailhead API"

here is the code I wrote below.  Any idea why I encountered "Challenge Not yet complete... here's what's wrong: 
The Apex class does not appear to be using the correct endpoint."? 

public class trailheadAPIChallenge {
    
    public static void getTrail(){
            
            // create a new HttpRequest object
            HttpRequest req = new HttpRequest();
            
            // get the current user's sessionId to use later as an access token for the Trailhead API Authorization
            string sid = UserInfo.getSessionId();
            //System.debug('session information ' + sid);
            
            // extend timeout to 20 seconds for slow responses
            req.setTimeout(20000);
            
            // create new response object for collecting the callout results
            HttpResponse res = new HttpResponse();
            Http http = new Http();
            
            // fill in the necessary settings for calling out to the Trailhead API:
            req.setEndpoint('https://api.trailhead.salesforce.com/v1/search/trails');
            req.setMethod('GET');
            req.setHeader('Content-Type', 'application/json; charset=utf-8');
            
            req.setHeader('X-API-Key', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');  //cannot expose X-API-Key
            req.setBody('{"status": "Active"}');
            req.setHeader('Authorization', 'Bearer ' + sid);

            // try to callout to the Trailhead API Rest API and if it doesn't work, catch the errors for debugging
            try {
                
                // send the http request and collect it in a response
                res = http.send(req);
                
                // serialize the resulting String into a map of name-value pairs (String-Object)
                Map<String, Object> jsonMap = (Map<String, Object>) JSON.deserializeUntyped(res.getBody()); 
                
                // get the total_count from the map
                Integer totalCount = (Integer)jsonMap.get('total_count');               
                
                // makes sure these are true
                System.assert(totalCount > 0);
                System.assertEquals(200, res.getStatusCode());

                // output to the logs in case you want to view the results
                System.debug('request: '+ req.toString());
                System.debug('response: '+ res.toString());
            
            } catch(System.CalloutException e) {
                System.debug('Callout error: '+ e);
                System.debug(res.toString());
            }
        }
    }
I tried to complete the badge API basics and got stuck at #Use SOAP API
 
I got the error: Challenge Not yet complete... here's what's wrong:  It doesn't appear that you have logged in using SoapUI.

I have verified I connected to the right org.  Could someone help here? 
I am not able to get through this challenge. 
I logged in through SOAPUI and used the session id to create an account. The account gets created and returns success. However when I try to validate the challenge in trailhead, it gives me an error - 

Challenge Not yet complete... here's what's wrong: 
It doesn't appear that you have logged in using SoapUI.

I am not sure what did I miss out.