Updating customer shipping address via Zoho Inventory API

Updating customer shipping address via Zoho Inventory API

My client is looking to add a functionality that will allow Zoho inventory to automatically update the City, State and Country fields on a customer record based on a zip code that they've entered. For example - if they enter 92705 as a zip code (US zipe code) the system will automatically update the following: City: Santa Ana, State: California, Country: United States

I was able to write a custom function that looks at the customer record, and calls the google maps API to retrieve the City, State and Country. I'm able to retreive the data i need from google maps API but running into an issue when trying to take the values i retrieved and update the customer shipping address. Below is the code i've used which doesn't work:

city = address.get(1).getJSON("long_name");  //parsing the Jason I received from google

state = address.get(3).getJSON("long_name");  //parsing the Jason I received from google

country = address.get(4).getJSON("long_name"); //parsing the Jason I received from google

mp = Map();  //declaring the response variable

mp.put("shipping_address[city]",city);

mp.put("shipping_address[state]",state);

mp.put("shipping_address[country]",country);

update = zoho.inventory.updateRecord("Contacts",organizationID,customerID,mp);


Looking at the JSON format I get using the GET command for a customer it seems like Shipping_address is on a nested level in the JSON (see attached file). I'm trying to figure out the correct syntax to update the shipping address. Any guidance/direction will be much appreciated! 

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now