You need to sign in to do that
Don't have an account?
forceDeveloper
Retrieve Rest API value
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,
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,
Please try below code, I wrote this code based on your JSON response if it helps for you please mark the best answer.
Thanks
Shaik