0
global class APTS_UsageInputWrapper {

    global String EQ_WorkId { get; set; }
    global Integer EQ_Count { get; set; }
    global Boolean ValidateOnly { get; set; }
    global List<APTS_UsageInputWrapperData> data { get; set; }
}

Web Service :

@RestResource(urlMapping='/UsageInput/') 
global class APTS_UsageInputWS {
   @HttpPost
    global static void loadUsageInputs ()
    { 
        RestRequest req =RestContext.request;
           Blob body = req.requestBody;
           String requestString = body.toString();
        APTS_UsageInputWrapper inputList = (APTS_UsageInputWrapper)JSON.deserialize(requestString,APTS_UsageInputWrapper.class);
        List<EQ_TempSSP1Data__c> tempData = new List<EQ_TempSSP1Data__c>();
        system.debug('***1');
        system.debug('%%%inputList');
        if(inputList.ValidateOnly)
        {
            validateData(inputList);
        }
        else
        {
            delete [select id from EQ_TempSSP1Data__c];
            Integer counter = 1;
            for(APTS_UsageInputWrapperData record : inputList.data)
            {
                tempData.add(new EQ_TempSSP1Data__c(EQ_WorkId__c = inputList.EQ_WorkId,
                            EQ_SourceSystem__c = record.EQ_SourceSystem,
                            EQ_IssueNumber__c = record.EQ_IssueNumber,
                            EQ_ServiceCode__c = record.EQ_ServiceCode,
                            EQ_Quantity__c = record.EQ_Quantity,
                            EQ_QuantityID__c = record.EQ_QuantityID,
                            EQ_RecordKey__c = record.EQ_RecordKey,
                            EQ_LoadMonth__c = Date.newInstance(Integer.valueOf(record.EQ_LoadMonth.left(4)), Integer.valueOf(record.EQ_LoadMonth.subString(4,5)), Integer.valueOf(record.EQ_LoadMonth.subString(6,7))),            
                            Name = counter + '-' + record.EQ_LoadMonth + '-' + record.EQ_IssueNumber));
                counter++;
            }
            insert tempData;
            system.debug('validation called%%%%');
            validateData(inputList);
        }


    }

JSON input:

{
 "EQ_Count":1,
 "EQ_WorkId":"B-080319-4",
 "ValidateOnly":False,
 "Data":
     [{"EQ_RecordKey":"ab3ff95a-42cc-4778-888d-e1f4c4beb78d",
     "EQ_LoadMonth":"20190101",
     "EQ_Quantity":32116,
     "EQ_ServiceCode":"trsactmata",
     "EQ_IssueNumber":"NW22",
     "EQ_SourceSystem":"SSP1",
     "EQ_QuantityID":"4737301"
     },
     {"EQ_RecordKey":"ab3ff95a-42cc-4778-888d-e1f4c4beb78d",
     "EQ_LoadMonth":"20190101",
     "EQ_Quantity":32116,
     "EQ_ServiceCode":"trsactmata",
     "EQ_IssueNumber":"NW22",
     "EQ_SourceSystem":"SSP1",
     "EQ_QuantityID":"4737301"
     }]
 }

While calling service from workbecnh getting error:

APEX_ERROR message: System.JSONException: Unexpected character ('F' (code 70)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at [line:4, column:18] Class.System.JSON.deserialize: line 15, column 1 Class.APTS_UsageInputWS.loadUsageInputs: line 14, column 1

3
  • 1
    Please edit your question and add APTS_UsageInputWrapper Always use {} tool with code, so it gets syntax highlighting. Jan 7, 2020 at 8:38
  • 1
    False is not a valid value for a property element in JSON. It is case sensitive
    – kurunve
    Jan 7, 2020 at 8:40
  • APTS_UsageInputWrapper added to question for more clarification Jan 7, 2020 at 8:40

1 Answer 1

1

Your json is invalid. The false value must be enclosed with quotes 'false'

Error: Parse error on line 4: ...", "ValidateOnly": False, "Data": [{
----------------------^ Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE'

2
  • thanks . got my mistake. Just changed from False to false it worked. Jan 7, 2020 at 8:42
  • Yes case sensitive.. putting it in quotes actually makes it a string.. so not really right answer.. glad you got it figured out!! Jan 7, 2020 at 8:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .