Creating Customer works fine, cannot update Contact Address via the API

drancourdrancour Member Posts: 8
edited November 2017 in Development
I am able to create a new customer via the API but I am unable to set the Contact address information using the API. After reviewing the API documentation I'm beginning to think the Contact address cannot be updated via the API.

Can you confirm if the Customer Contact address information can be updated via the API?

9 comments

  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    You can set the contact info by including it as a sub-object, like this:
    {
    "firstName": "Joe",
    "lastName": "Customer",
    "Contact": {
    "custom": "Random Customer Info",
    "noEmail": "false",
    "noPhone": "true",
    "noMail": "false",
    "Addresses": {
    "ContactAddress": {
    "address1": "700 St-Antoine Est",
    "address2": "Suite 300",
    "city": "Montreal",
    "state": "QC",
    "zip": "H2Y 1A6",
    "country": "Canada"
    }
    },
    "Phones": {
    "ContactPhone": {
    "number": "866 932 1801",
    "useType": "Work"
    }
    },
    "Emails": {
    "ContactEmail": {
    "address": "[email protected]",
    "useType": "Primary"
    }
    },
    "Websites": {
    "ContactWebsite": {
    "url": "http://www.lightspeedhq.com"
    }
    }
    }
    }
    See also: http://developers.lightspeedhq.com/retail/introduction/relations/
    James Ratcliffe
    Lightspeed HQ
  • drancourdrancour Member Posts: 8
    Thanks James - I am using the XML end points. However I am not able to update the Contact information, I am getting "Bad Request" back. Can you see what I'm doing wrong? Here's an example (data anonymized):

    To the new customer end point:
    https://api.merchantos.com/API/Account/acctIdHere/Customer/11.xml
    <?xml version="1.0" encoding="utf-16"?>
    
      
      A & M
      
      A & M
      
      
      0
      2
      0
      0
      11
      2017-11-04T17:08:19+00:00
      2017-11-04T17:08:19+00:00
      false
      
        
        false
        false
        false
        
          
            123 That Street
            
            Phoenix
            AZ
            12345
            USA
          
        
        
        
        
        2017-11-04T17:08:19+00:00
      
    
    
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    You should check the response body. It will indicate that you're specifying an invalid text encoding. Use "utf-8" instead.
    James Ratcliffe
    Lightspeed HQ
  • drancourdrancour Member Posts: 8
    That's got it! Thank you James!!
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    You're welcome
    James Ratcliffe
    Lightspeed HQ
  • drancourdrancour Member Posts: 8
    Hey James - one more question related to this, is it possible to create a new customer with all the contact information in 1 call? Basically I'm having to do a POST to create the new customer with the company name/last name, then do a PUT to update with the contact information. Due to the rate limiting, this costs 20 units per customer - my customers' bucket is only 60 units so processing 100 customers takes ~30 minutes. If I could do this in 1 call I could double my processing, but when I tried to send the whole new object I get 422 - Unprocessable Entity.

    Should it be possible to create the customer with all information in 1 call?
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    edited November 2017
    Yes, you just include all the contact information like I did in the example. If you're getting a 422 error, the response body will give you more details.
    Post edited by jamesratcliffe on
    James Ratcliffe
    Lightspeed HQ
  • drancourdrancour Member Posts: 8
    Thanks James - I see the problem, archive cannot be specified for create:

    Customer not Created. "archived" cannot be set on Create.
  • jamesratcliffejamesratcliffe Administrator, Lightspeed Staff Posts: 160 moderator
    You’re welcome.

    You generally can't set the "archived" field directly. You have to use the DELETE method.
    James Ratcliffe
    Lightspeed HQ
Sign In or Register to comment.