+ Start a Discussion
veeranjaneyuluveeranjaneyulu 

restapi HttpPost Method

Hi,

I have written one restapi post method class. when i am trying to execute this api class through workbench . i am facing below error please help me out.

restExplorer Url Mapping :"/services/data/apexrest/dpWebPlanChg1"





 
@RestResource(urlMapping='/dpWebPlanChg1/*')
global without sharing class DPWebPlanChange2017Dump {

public class DPWebPlanChange2017Exception extends Exception{}
    
@HttpPost
    global static DirectPayResponse getDPWebPlanChangeData(DPWebPlanChange directPlanTrackerVar) {
    
    
        
        DirectPayResponse plnChngRes = new DirectPayResponse();
        
        system.debug('....restResponse...'+plnChngRes);
        
        // Get Account details
        Account updateAcc = getMemberData(directPlanTrackerVar.ssn, directPlanTrackerVar.dob, directPlanTrackerVar.FName, directPlanTrackerVar.LName);
        if(updateAcc != null) {
            //Insert Direct pay Plan Change Tracker record along with old values of Account
            plnChngRes = createDirectPayTrackerRecord(directPlanTrackerVar, updateAcc, plnChngRes);
            if(plnChngRes.result == 'ERROR')
                return plnChngRes;
            
            //Update Account only if it is Direct Pay
            //If a customer has enrolled for both Medicare and Direct Pay then that account will not be updated
            if(updateAcc.Medicare_Claim_Number_new__c == null){
                plnChngRes = updateDirectPayAccount(directPlanTrackerVar, updateAcc, plnChngRes);
                if(plnChngRes.result == 'ERROR')
                    return plnChngRes;
            }   
        } 
        
        //If Account not found
        else{
            //Insert Direct pay Plan Change Tracker record
            plnChngRes = createDirectPayTrackerRecord(directPlanTrackerVar, null, plnChngRes);
            if(plnChngRes.result == 'ERROR')
                return plnChngRes;
            
            //Insert Account if not exists
            plnChngRes = insertDirectPayAccount(directPlanTrackerVar, plnChngRes);
            if(plnChngRes.result == 'ERROR')
                    return plnChngRes;
        }

        //Insert Opportunity 
        plnChngRes = insertDirectPayOpportunity(directPlanTrackerVar, plnChngRes);
        if(plnChngRes.result == 'ERROR')
            return plnChngRes;

        
        //Update Direct pay Plan Change Tracker record with Opportunity and Account
        plnChngRes = updatePlanChangeTrackerRecord(plnChngRes);
        if(plnChngRes.result == 'ERROR')
            return plnChngRes;
        
        
        return plnChngRes;
    }

    //Get Account record based on DOB, SSN, First Name and Last Name
    private static Account getMemberData(String SSN, String dob, String firstName, String LastName) {
        Account accdata = new Account();
        try {
            accdata = [Select Id, Marital_Status__c, Primary_Language__c,Phone, PersonBirthdate,
                       PersonMobilePhone, PersonEmail, Physical_Address_Line_1__c, Medicare_Claim_Number_new__c,
                       Physical_City__c, Physical_State__c, Physical_Zip_Code__c, Mailing_State__c, 
                       Mailing_Address_Same_As_Home_Address__c, Mailing_Address_Line_1__c, Mailing_City__c,
                       Mailing_Zip_Code__c, Primary_care_physician_name__c, Physician_Address__c, Physician_State__c,
                       Physician_City_town__c, Physician_Zip_code__c FROM Account WHERE LastName = : LastName
                       AND FirstName = : firstName AND PersonBirthdate = : date.parse(dob) LIMIT 1];
        } 
        catch (Exception e) {
            system.debug('Exception Occured' + e.getMessage());
            return null;
        }
            return accdata; 
    }


Raw Response
HTTP/1.1 404 Not Found Date: Fri, 14 Oct 2016 07:17:44 GMT Set-Cookie: BrowserId=yTCuswHmRoKXZvYgWh5Zgw;Path=/;Domain=.salesforce.com;Expires=Tue, 13-Dec-2016 07:17:44 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked
[ { "errorCode" : "NOT_FOUND", "message" : "The requested resource does not exist" } ]


 
Vivek DVivek D
// You don't have anything in the URL so change the class urlmapping
@RestResource(urlMapping='/dpWebPlanChg1')

 
veeranjaneyuluveeranjaneyulu
Hi Vivek,

I have tried it but not working, same error i got