Blank new Client and Contact when trying to update using the id

Hi everyone,

I really hope some can help me with updating an existing contact and client.

I am trying to pass Salesforce record id’s into the custom fields on contacts, but iterating over the ‘Update a client’ option in Integromat doesn’t seem to be possible. Passing in a contact id doesn’t seem to update an existing record, and instead overrides/creates a new one.

I’ve since tried to make an API post request using the client id but that only seems to create a new client with blank information. I’ve included some of the commands I’ve tried below along with the result and expected outcome.

Data (truncated):

{
"data": {
    "id": 1,
    "name": "Test & Test2 Thornton",
    "display_name": "Test & Test2 Thornton",
    "address1": "1215 Water Fall Way",
    "id_number": "",
    "custom_value1": "",
    "contacts": [
        {   "id": 2,
            "first_name": "Contact1",
            "last_name": "Thornton",
            "email": "jihan@fillnoo.com",
            "phone": "5555555555",
            "custom_value1": ""
        },
        {   "id": 3,
            "first_name": "Contact2",
            "last_name": "Thornton",
            "email": "jihan.thornton@fillnoo.com",
            "phone": "3333333333",
            "custom_value1": ""}
    ] }
}


Attempt 1: Access Client directly

curl --location -g --request POST '${host}/api/v1/clients/1' \
--header 'Content-Type: application/json' \
--header 'X-Ninja-Token: TOKEN' \
--header 'X-Requested-With: XMLHttpRequest' \
--data-raw '{"contacts": [{"id": 2,"custom_value1": "newid"}]}'
  • Expected: For custom_value1 of Contact1 to change to “newid”
  • Postman Result: Returns unchanged client
  • Terminal Result: Symfony throws “MethodNotAllowedHttpException”


Attempt 2: Changed url and attempted to filter using client_id

curl --location -g --request POST '${host}/api/v1/clients' \
--header 'Content-Type: application/json' \
--header 'X-Ninja-Token: TOKEN' \
--header 'X-Requested-With: XMLHttpRequest' \
--data-raw '{"client_id": "1","contacts": [{"id": 2,"custom_value1": "newid"}]}'
  • Expected: For custom_value1 of Contact1 to change to “newid”
  • Postman Result: Returns unchanged clients
  • Terminal Result: Creates new blank contact and client


Attempt 3: Changed url and attempted to change contact directly using id

curl --location -g --request POST '${host}/api/v1/contacts/2' \
--header 'Content-Type: application/json' \
--header 'X-Ninja-Token: TOKEN' \
--header 'X-Requested-With: XMLHttpRequest' \
--data-raw '{"id": 2,"custom_value1": "newid"}'
  • Expected: For custom_value1 of Contact1 to change to “newid”
  • Postman Result: Returns unchanged clients
  • Terminal Result: Symfony throws “MethodNotAllowedHttpException”


I’m really hoping this is a typo or missing header situation; in case it isn’t though I’d really appreciate either guidance on how to accomplish updating an existing client without overriding it or debugging this.

Thanks in advance

Hi,

To update a client you need to send a PUT request to /clients

https://invoice-ninja.readthedocs.io/en/latest/api.html#updating-data

When I try to use PUT it overrides the two existing contacts and creates a blank new one with an incremented id.

Are you including the original contacts with their ids?

Yes, this is what I’m passing in
{“contacts”:[{“id”: 2, “first_name”: “test”}]}

I suggest trying the cURL sample from the docs linked above

Using the sample in the docs didn’t work for me in postman or the terminal, but it does exactly what I need it to now in Integromat! Thanks Hillel