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
Nidhi L SharmaNidhi L Sharma 

Challenge Not yet complete... here's what's wrong: Could not find an inner class named 'QueueablePMSCall' that implements System.Queueable and Database.AllowsCallouts.

Hi everyone!,

I am stuck on the suerbadge challenge:
Data Integration Specialist #3 Synchronize Salesforce opportunity data with Square Peg's PMS external system

This is my code:
 
public class ProjectCalloutService {
    public static Id opportunityId;
    
    @InvocableMethod
    public static void postOpportunityToPMS(List<Id> opportunityIds){
        opportunityId=opportunityIds.get(0);
        Opportunity opp=[Select Id,Name, closeDate,amount,Account.Name FROM Opportunity Where Id =: opportunityId];
        ID jobID = System.enqueueJob(new QueueablePMSCall(opp));
    }    
    
    public class QueueablePMSCall implements Queueable,Database.AllowsCallouts
    {
        private String jsonOpp;
        private Opportunity opportunityObject;
        public QueueablePMSCall(Opportunity opp)
        {
            opportunityObject=opp;
            JSONGenerator gen = JSON.createGenerator(true);
            gen.writeStartObject();
            gen.writeStringField('opportunityId', opp.Id);
            gen.writeStringField('opportunityName', opp.Name);
            gen.writeStringField('accountName', opp.account.Name);
            gen.writeDateField('closeDate', opp.closeDate);
            gen.writeNumberField('amount', opp.amount);
            
            gen.writeEndObject();            
            
            jsonOpp= gen.getAsString();
            System.debug('jsonOpp: ' + jsonOpp);
            
        }
        public void execute(QueueableContext context) {
            
            ServiceTokens__c token= ServiceTokens__c.getValues('ProjectServiceToken');
            System.debug(token.Token__c);
            
            // create an HTTPrequest object    
            HttpRequest req = new HttpRequest();
            req.setMethod('POST');
            req.setEndpoint('callout:ProjectService/'+ token.Token__c);
            req.setHeader('Content-Type', 'application/json');
            req.setBody(jsonOpp);    
            
            // create a new HTTP object
            Http http = new Http();
            HTTPResponse res = http.send(req);
            if (res.getStatusCode() != 201) {
                System.debug('Error from ' + req.getEndpoint() + ' : ' +
                             res.getStatusCode() + ' ' + res.getStatus());
                
                Opportunity opportunity1=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity1.StageName='Resubmit Project';
                update opportunity1;
                
            }
            else {
                Opportunity opportunity2=[Select Id, StageName FROM Opportunity Where Id =: opportunityObject.Id];
                opportunity2.StageName='Submitted Project';
                update opportunity2;
            }      
        }
        
    } 
}

Thanks
Best Answer chosen by Nidhi L Sharma
Nidhi L SharmaNidhi L Sharma
I found the solution. 
It  was looking for System.Queueable (not Queueable). It was simple but took so many hours to resolve it.
My post may help someone else in such trouble.
Thanks.

All Answers

Nidhi L SharmaNidhi L Sharma
I am able to run it successfully. It updates the stage of Opportunity to 'Submitted Project' perfectly.  But why it is not recognizing my inner class QueueablePMSCall?
Nidhi L SharmaNidhi L Sharma
I found the solution. 
It  was looking for System.Queueable (not Queueable). It was simple but took so many hours to resolve it.
My post may help someone else in such trouble.
Thanks.
This was selected as the best answer
Shreyas Dhond 16Shreyas Dhond 16
You are supposed to include the token in the header of your request with key "Token" according to the challenge description.
Gupta.VishalGupta.Vishal
@Nidhi Sharma , you saved my day Thankyou so much