How to update custom field values for Customer

I'm writing a sync between Lightspeed and another system. I want to store my external customerId in Lightspeed, using a custom field.

So, i've created a custom field for that, but unfortunately i cannot update custom fields using the API.

How can I accomplish this?


Thanks,

Arjan

6 comments

  • LucienVersendaalLucienVersendaal Moderator, Lightspeed Staff Posts: 734 moderator

    Hi @arjanduijzer,

    Thank you for contacting us.

    You can do this by using the following payload in the customer endpoint.

    PUT /Customer/{customer_id}.json
    

    Payload:

    {
    	"CustomFieldValues": {
                "CustomFieldValue": {
                    "customFieldID": "2",
                    "type": "string",
                    "value": "123456789"
                }
            }
    }
    

    I hope this helps.

  • arjanduijzerarjanduijzer Member Posts: 2

    Thanks for your answer. I've tested this from my code, but unfortunately it seems not working. The field value is not updated (not in result and not in Lightspeed)


    This is my request, specially the field "WWMRelationId"



    PUT https://api.lightspeedapp.com/API/Account/164996/Customer/1 HTTP/1.1

    Accept: application/json

    Authorization: Bearer *************

    Cookie: __cfduid=************

    Content-Type: application/json; charset=utf-8

    Content-Length: 926

    Host: api.lightspeedapp.com


    {"customFieldValue":[{"customFieldValueID":294,"customFieldID":2,"name":"Nieuwsbrief","type":"boolean","value":"true"},{"customFieldValueID":1089,"customFieldID":7,"name":"Erkenningnummer","type":"string","value":"12345"},{"customFieldValueID":1090,"customFieldID":4,"name":"Jachtaktenummer","type":"integer","value":"1"},{"customFieldValueID":1091,"customFieldID":5,"name":"Verlofnummer","type":"integer","value":"2"},{"customFieldValueID":1092,"customFieldID":6,"name":"Verona Clientnummer","type":"integer","value":"3"},{"customFieldValueID":1093,"customFieldID":3,"name":"Erkenninghouder","type":"boolean","value":"true"},{"customFieldValueID":1124,"customFieldID":1,"name":"Membership","type":"single_choice","value":{"customFieldChoiceID":"1","name":"Standaard","value":"","canBeDeleted":"false","customFieldID":"1"}},{"customFieldValueID":1133,"customFieldID":8,"name":"WWMRelationId","type":"integer","value":"3964"}]}

  • indyhendrickxindyhendrickx Member Posts: 6

    For multiple custom fields:

    '{"CustomFieldValues": {"CustomFieldValue": [{ "customFieldID": "13", "type": "integer", "value": "0"}, {"customFieldID": "8", "type": "boolean", "value": "false"}]}}'

  • rayvanbrayvanb Member Posts: 6

    Hi there,

    I'm trying to do something similar, but the api throws this:

    {

    "error": {

    "code": 403,

    "method": "UPDATE",

    "request": "/nl/customers/103060641.json",

    "message": "The server understood the request, but is refusing to fulfill it."

    }

    }

    Any advice?


    Thanks,

    Raymond

  • gregaricangregarican Member Posts: 683 

    Do you API credentials have scope permissions to modify customers? What does your request body look like?

  • rayvanbrayvanb Member Posts: 6

    Hi Gregarcian,

    Didn't look at that, checked it and it seems i only have read permissions :-/

Sign In or Register to comment.