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
king kpking kp 

How POST Account Information JSON format using Apex

Hi ,

How POST Account Information JSON format using Apex.Could You Please Help Me

Thanks 
kullayappa 
harsha__charsha__c
String s = JSON.serialize(objectToSerialize, suppressApexObjectNulls)

This should get your job done!

Ref : https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm

- Harsha
king kpking kp
Hi Harsha,

Thanks For Reply, If Dont Mine Could please Send Me Entire Code Please Iam Trying to this code

public class JSONParserUtilt {
    @future(callout=true)
    public static void parseJSONResponse() {        
        HttpRequest req= new HttpRequest();
            req.setMethod('POST');
            String username = 'kullayappa.adapala@config-consultants.com';
            String password = 'Kull@i12345'; 
            Blob headerValue = Blob.valueOf(username + ':' + password);
            String authorizationHeader = 'Basic  ' + EncodingUtil.base64Encode(headerValue);
            req.setHeader('Authorization', authorizationHeader);
            Http http = new Http();       
            String url = 'https://cacf-test.crm.us2.oraclecloud.com/crmCommonApi/resources/latest/accounts';
            req.setEndpoint(url );
            HttpResponse res = http.send(req);
            //return res.getBody(); 
       System.debug('@@@@@@@@@@@@'+res.getBody());

        // Parse JSON response to get all the totalPrice field values.
        JSONParser parser = JSON.createParser(res.getBody());
        Double grandTotal = 0.0;
        while (parser.nextToken() != null) {
            if ((parser.getCurrentToken() == JSONToken.FIELD_NAME) && 
                (parser.getText() == 'PartyId')) {
                // Get the value.
                parser.nextToken();
                System.debug('44444444444444444'+parser.getCurrentName());

                // Compute the grand total price for all invoices.
                grandTotal += parser.getDoubleValue();
            }else{
                System.debug('********************'+parser.getText());

            }
        }
        system.debug('>>>>>>>>>>>>>>>>>>>>>>>' + grandTotal);
    }   
}