• forceDeveloper
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 1
    Replies
Hi All,

I am using this code .
Map<String, Object> results = (Map<String, Object>) JSON.deserializeUntyped(res.getBody());
                    System.debug('results::'+results);
                    System.debug('results.get()::'+results.get('items'));


 I want to get the "customer_id" in apex
{items=({addresses=({city=ewing, country_id=US, customer_id=18,  firstname=nini, id=19, lastname=nini, postcode=08628, region={region=New Jersey, region_code=NJ, region_id=41}, ...}),
 , custom_attributes=({attribute_code=phone_number, value=1231231234}, {attribute_code=account_number, value=147439}), default_billing=19,  email=ninin@example.com, firstname=nini, group_id=0, ...}), 
search_criteria={filter_groups=({filters=({condition_type=eq, field=email, value=ninin@example.com})})}, 
total_count=1}

When I using   System.debug('results.get()::'+results.get('items'));  . I am getting the below value 

({addresses=({city=ewing, country_id=US, customer_id=18, default_billing=true, default_shipping=true, firstname=nini, id=19, lastname=nini, postcode=08628, region={region=New Jersey, region_code=NJ, region_id=41}, ...}), created_at=2019-01-02 15:58:29, created_in=Default Store View, custom_attributes=({attribute_code=phone_number, value=1231231234}, {attribute_code=account_number, value=147439}), default_billing=19, default_shipping=19, disable_auto_group_change=0, email=ninin@example.com, firstname=nini, group_id=0, ...})

results.get('items').get("addresses") -- is not working

Please help me to get the "customer_id" value.
Thanks,
 
Hi to All,

I am new in SF Integration. I am making a POST call using REST Api and getting the error.

My Code:
global class AccountMagentoSync{
    
   @future(callout=true)
    public static void AccountUpdate(String id,String firstName,String lastName,String email){

        if(consumerKey!=null){

            //String endPoint='https://requestbin.fullcontact.com/12k5hkb1/';
            String endPoint='https://pro-stage.cdeuat.com/rest/V1/customers/';
            String jsonstr='{"email":"'+email+'","firstName":"'+ firstName +'","lastname":"'+ lastName +'","storeId":"'+ Integer.ValueOf('1') +'","websiteId":"'+ Integer.ValueOf('1')+'"}';
   
            System.debug('###jsonstr:::'+jsonstr);
            Http h2= new Http();
            HttpRequest req2= new HttpRequest();
            req2.setHeader('Authorization','Bearer ' + consumerKey);
            req2.setHeader('Content-Type','application/json');            
            req2.setHeader('Accept','application/json');
            req2.setBody(jsonstr);
            req2.setMethod('POST');
            req2.setEndpoint(endPoint);
            HttpResponse res2=h2.send(req2);
            System.debug('###req2:::'+req2);
            System.debug('###Res2:::'+res2);
            
            if (res2.getStatusCode() == 200) {
                System.debug('The status code returned as expected: ' +
                             res2.getStatusCode() + '---' + res2.getStatus());
            }

        }
    }
    }

Error I am getting :
10:59:32.14 (14718389)|CODE_UNIT_STARTED|[EXTERNAL]|01p0x000000FRwF|AccountMagentoSync.AccountUpdate(String, String, String, String)
10:59:32.14 (15381092)|USER_DEBUG|[15]|DEBUG|###jsonstr:::{"email":"try@gmail.com","firstName":"userFirstName","lastname":"userLastName","storeId":"1","websiteId":"1"}
10:59:32.14 (296125668)|USER_DEBUG|[25]|DEBUG|###req2:::System.HttpRequest[Endpoint=https://pro-stage.cdeuat.com/rest/V1/customers/, Method=POST]
10:59:32.14 (296169241)|USER_DEBUG|[26]|DEBUG|###Res2:::System.HttpResponse[Status=Bad Request, StatusCode=400]

Please help to resolve this issue

Any help is highly appreciated
Hello,
I am trying to Deactivate the trigger using Workbench and getting error "No package.xml is found".
However, I am using the package.xml  and destructiveChanges.xml .

I am uploading the package.zip in the Workbench still I am getting the error.

package.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>43.0</version>
</Package>

destructiveChanges.xml :-
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata"> 
  <types>
    <members>AccountAddressTrigger</members>
    <name>ApexTrigger</name>
    <status>Inactive</status>
  </types> 
<version>41.0</version>
</Package>

Workbench Error

Any help woul be much appreciated.

Thanks,
Hello,
I am trying to Deactivate the trigger using Workbench and getting error "No package.xml is found".
However, I am using the package.xml  and destructiveChanges.xml .

I am uploading the package.zip in the Workbench still I am getting the error.

package.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <version>43.0</version>
</Package>

destructiveChanges.xml :-
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata"> 
  <types>
    <members>AccountAddressTrigger</members>
    <name>ApexTrigger</name>
    <status>Inactive</status>
  </types> 
<version>41.0</version>
</Package>

Workbench Error

Any help woul be much appreciated.

Thanks,