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
Arshad Rasheed 11Arshad Rasheed 11 

Data Integration Superbadge

Hello All,

Any idea about below error message? I am trying to implement service for Inbound Project Data (ProjectRESTService) 

10:14:46.0 (2966919)|EXCEPTION_THROWN|[EXTERNAL]|System.JSONException: Value does not match expected type at [line:1, column:179]

Thanks,
NagendraNagendra (Salesforce Developers) 
Hi Arshad,

Below is the code which works fine for me.
@RestResource(urlMapping='/project/*')
global with sharing class ProjectRESTService {
  @HttpPost
  global static String postProjectData(String ProjectRef, String ProjectName, String OpportunityId, Date StartDate, Date EndDate, Double Amount, String Status) {
      List<Project__c> projects = [SELECT Billable_Amount__c,End_Date__c,Id,Name,Opportunity__c,ProjectRef__c,Start_Date__c,Status__c FROM Project__c WHERE ProjectRef__c = :ProjectRef];
      Project__c project = new Project__c();
      if(projects.size() > 0)
          project = projects.get(0);
      
      Savepoint sp = Database.setSavepoint();
      try{
          project.Billable_Amount__c = Amount;
          project.End_Date__c = EndDate;
          project.Name = ProjectName;
          project.Opportunity__c = OpportunityId;
          project.ProjectRef__c = ProjectRef;
          project.Start_Date__c = StartDate;
          project.Status__c = Status;
          upsert project;
          
          //Update Opportunity
          Opportunity opportunity = [SELECT Id, DeliveryInstallationStatus__c FROM Opportunity WHERE Id = :OpportunityId];
          opportunity.DeliveryInstallationStatus__c = 'In progress';
          update opportunity;
          
          return 'OK';
      }
      catch(exception ex){
          Database.rollback(sp);
          return ex.getMessage();
      }
   }
}
Hope this helps.

Kindly mark this as solved if my reply was helpful.

Regards,
Nagendra
 
Arshad Rasheed 11Arshad Rasheed 11
Hi Nagendra,

Thanks for the response. I tried your code but iam still getting the same error. I dont think this error is related to the code as i have tried executing empty method as shown below.
I have recheked all the configurations in custom setting, remote site setting and connected app. everything looks ok but the error is still there. any suggestions ?

@RestResource(urlMapping='/project/*')
global with sharing class ProjectRESTService {
  @HttpPost
  global static String postProjectData(String ProjectRef, String ProjectName, String OpportunityId, Date StartDate, Date EndDate, Double Amount, String Status) {
  
      return null;
      
   }
}

thanks,