API - Update One field

I am new when it comes to API’s, im trying to update one client field (custom_value4)

If i do a PUT method, it removes the contact info. I tried doing a PATCH, but get "this method is not supported for this route.

This is what im using, any suggestions? Thanks again for all the help!

PATCH /v1/clients/X46dBXa79j HTTP/1.1
Authorization: Bearer TOKENHERE
Host: billing.domain.com
Accept: application/json
Content-Type: application/json
Content-Length: 63

{
"data" : {
    "custom_value4": "mydatahere",
}

}

@TomTom88

Contacts are tightly integrated with clients, so you’ll want to PUT the entire client object along with the contacts array. If you pass no contacts, this effectively deletes all the contacts.

Gotcha, so just to make sure, if i do a curl with a GET request with a client ID. All of the fields i get in the response would need to be put into the PUT request?

@david

So this is my PUT below…
-Contact First / Last Email & phone are getting blanked out
-custom_value3, custom_value4 is not getting set
-Invoice Payment Terms is getting blanked

Is there something wrong with the formatting of my PUT?

{
“data”: {
“id”: “xYRdG7dDzO”,
“user_id”:“VolejRejNm”,
“assigned_user_id”: “VolejRejNm”,
“name”: “Once Again”,
“website”: “”,
“private_notes”: “Heres the private note”,
“balance”: 0,
“group_settings_id”: “”,
“paid_to_date”: 0,
“credit_balance”: 0,
“last_login”: 0,
“size_id”: “”,
“public_notes”: “”,
“client_hash”: “ZhBwEfbPuFqiWdo6ck7ADVubWOgIU7hyFrtANHua”,
“address1”: “1122 Street Dr”,
“address2”: “”,
“phone”: “1234567890”,
“city”: “ThisPlace”,
“state”: “WA”,
“postal_code”: “11111”,
“country_id”: “840”,
“industry_id”: “”,
“custom_value1”: “No”,
“custom_value2”: “NA”,
“custom_value3”: “VRDZXNMQ08TBF140VP42DB916C”,
“custom_value4”: “http://www.domain.com/example”,
“shipping_address1”: “1122 Street Dr”,
“shipping_address2”: “”,
“shipping_city”: “ThisPlace”,
“shipping_state”: “WA”,
“shipping_postal_code”: “11111”,
“shipping_country_id”: “840”,
“settings”: {
“language_id”: “1”,
“currency_id”: “1”,
“payment_terms”: 0,
“valid_until”: “30”,
“default_task_rate”: 60,
“send_reminders”: true
},
“is_deleted”: false,
“vat_number”: “”,
“id_number”: “”,
“updated_at”: 2022-07-09T02:10:05.000Z,
“archived_at”: 0,
“created_at”: 2022-07-09T02:10:05.000Z,
“display_name”: “Once Again”,
“number”: “014”,
“contacts”: [
{
“id”: “Volej2RejN”,
“first_name”: “Once”,
“last_name”: “Again”,
“email”: “one@again.com”,
“created_at”: 2022-07-09T02:10:05.000Z,
“updated_at”: 2022-07-09T02:10:05.000Z,
“archived_at”: 0,
“is_primary”: true,
“is_locked”: false,
“phone”: “1234567890”,
“custom_value1”: “”,
“custom_value2”: “”,
“custom_value3”: “”,
“custom_value4”: “”,
“contact_key”: “8bnxaiJICCt1HVInNEY0sAOP9K4HIGAagDDPhF2v”,
“send_email”: true,
“last_login”: 0,
“password”: “”,
“link”: “https://billing.domain.com/public/client/key_login/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
}
],
}
}

Here is an example payload that works for me

{
    "group_settings_id": "",
    "name": "Boyer-Hahn",
    "display_name": "Boyer-Hahn",
    "balance": 14092.64,
    "credit_balance": 0,
    "paid_to_date": 0,
    "client_hash": "FmS0adAVnppX8D5JlOdXRxb1tmvNMgzFPn4nOirF",
    "address1": "72939",
    "address2": "8779 Oswald Hill",
    "city": "North Tina",
    "state": "Illinois",
    "postal_code": "31844-2028",
    "country_id": "348",
    "phone": "",
    "private_notes": "Beatae laudantium corporis quis. Saepe ratione exercitationem occaecati et. Doloremque rerum ut impedit error. Quod enim fugiat modi tempore autem.",
    "public_notes": "",
    "website": "http://www.renner.biz/quia-odio-ipsum-iste.html",
    "industry_id": "",
    "size_id": "",
    "vat_number": "545990965",
    "id_number": "",
    "number": "0001",
    "shipping_address1": "389",
    "shipping_address2": "206 Tremblay Lock",
    "shipping_city": "West Jordynland",
    "shipping_state": "Wisconsin",
    "shipping_postal_code": "96455",
    "shipping_country_id": "4",
    "settings":
    {
        "currency_id": "1"
    },
    "last_login": 0,
    "custom_value1": "",
    "custom_value2": "",
    "custom_value3": "",
    "custom_value4": "",
    "contacts":
    [
        {
            "first_name": "Kelsie",
            "last_name": "Luettgen",
            "email": "user@example.com",
            "password": "**********",
            "phone": "(678) 822-2574",
            "contact_key": "JEnd18itfJ49yZa7UtnCbWgdRq16lHH2pRqbfCOJ",
            "is_primary": true,
            "send_email": true,
            "custom_value1": "xx",
            "custom_value2": "xx",
            "custom_value3": "xx",
            "custom_value4": "",
            "last_login": 0,
            "link": "http://ninja.test:8000/client/key_login/JEnd18itfJ49yZa7UtnCbWgdRq16lHH2pRqbfCOJ",
            "created_at": 1657239899,
            "updated_at": 1657239899,
            "archived_at": 0,
            "id": "Jxbo27zagw"
        },
        {
            "first_name": "Blaise",
            "last_name": "Kling",
            "email": "tara.mayer@example.org",
            "password": "**********",
            "phone": "1-818-457-2917",
            "contact_key": "o8AldX8RnmQ6Rd30v5W5fMCvC6NOATtYJer8rUns",
            "is_primary": false,
            "send_email": true,
            "custom_value1": "",
            "custom_value2": "",
            "custom_value3": "",
            "custom_value4": "",
            "last_login": 0,
            "link": "http://ninja.test:8000/client/key_login/o8AldX8RnmQ6Rd30v5W5fMCvC6NOATtYJer8rUns",
            "created_at": 1657239899,
            "updated_at": 1657239899,
            "archived_at": 0,
            "id": "8mepY71aMy"
        }
    ],
    "activities":
    [],
    "ledger":
    [],
    "gateway_tokens":
    [],
    "documents":
    [],
    "system_logs":
    [],
    "created_at": 1657239899,
    "updated_at": 1657239900,
    "archived_at": 0,
    "id": "k8mepoQdMy",
    "is_deleted": false,
    "user_id": "Opnel2lbKB",
    "assigned_user_id": ""
}

Hey @david

I am really struggling with this, im trying to use make.com scenario triggered with a create client webhook. The Scenario “get client” info from ninja (specifically client link) send the link to a service to get a tiny link, then the scenario updates ninja with this link trying to set custom_value4. I tried using the built in “update client” that make has for ninja, however when i do it wipes out things like currency id, language id, invoice terms, quote valid, etc. So now im trying to do an API call, i used the payload that you provided, i mapped all the fields to the api from the “get client”, however when it runs i get no contact data (first / last / email & phone area all wiped out)…

Any suggestions?
Thanks for the help, sorry to be a pest

@TomTom88

Can you show a full snippet of your code please.

Hey @david

chrome_DNtZ5s68Cj

So in the make.com scenario im doing the address https://billing.restassured.tech/api/v1/clients/1YQdJ2dOGp

Body is…

{
    "group_settings_id": "",
    "name": "Here Again",
    "display_name": "Here Again",
    "balance": 0,
    "credit_balance": 0,
    "paid_to_date": 0,
    "client_hash": "03GJNF1JObbrAmwR15RjfYitRkgi965pS3WNVaKA",
    "address1": "123 address",
    "address2": "",
    "city": "CityHere",
    "state": "WA",
    "postal_code": "11122",
    "country_id": "840",
    "phone": "5091111111",
    "private_notes": "This is the private Note",
    "public_notes": "",
    "website": "https://www.domain.com",
    "industry_id": "",
    "size_id": "",
    "vat_number": "",
    "id_number": "",
    "number": "015",
    "shipping_address1": "123 address",
    "shipping_address2": "",
    "shipping_city": "CityHere",
    "shipping_state": "WA",
    "shipping_postal_code": "11122",
    "shipping_country_id": "840",
    "settings":
    {
        "currency_id": "1"
	"language_id": "1",
        "payment_terms": ,
        "valid_until": "30",
        "default_task_rate": 60,
        "send_reminders": true
    },
    "last_login": 0,
    "custom_value1": "No",
    "custom_value2": "MySelf",
    "custom_value3": "5Z5H9QVE9GR3DEFFEGTCWQQVKG",
    "custom_value4": "https://domain.dom/HereAgain",
    "contacts":
    [
        {
            "first_name": "Here",
            "last_name": "Again",
            "email": "tom@xyz.com",
            "password": "",
            "phone": "5091111111",
            "contact_key": "AHuezjKsoOSh7jCBpxHHsJTIhjOd6ML9rEbZmmBL",
            "is_primary": true,
            "send_email": true,
            "custom_value1": "",
            "custom_value2": "",
            "custom_value3": "",
            "custom_value4": "",
            "last_login": 0,
            "link": "https://domain.dom/public/client/key_login/AHuezjKsoOSh7jCBpxHHsJTIhjOd6ML9rEbZmmBL",
            "created_at": 2022-07-09T19:05:38.000Z,
            "updated_at": 2022-07-09T19:05:38.000Z,
            "archived_at": 0,
            "id": "OpnelO5dKB"
        },
    ],
    "created_at": 2022-07-09T19:05:38.000Z,
    "updated_at": 2022-07-09T19:05:38.000Z,
    "archived_at": 0,
    "id": "1YQdJ2dOGp",
    "is_deleted": false,
    "user_id": "VolejRejNm",
    "assigned_user_id": "VolejRejNm"
}

@david

my knowledge of API’s is limited, i havnt been able to test this outside of make.com.

Do you know of some site i can send the same content to see if its a make.com issue?

Thanks for the help!

@TomTom88

I’m not too familiar with Makes platform, i was able to get the client update working, however it looks like you are passing a body up, It may be worth raising a support query with Make to ask them if you need to do anything in particular.

@david

I’ve opened a ticket with them. Is there a way of testing the payload outside or make.com that you know of? I’ve tried using a curl command but with the amount of data, it reports errors (probably have formatting wrong)

Thanks for all the help!

Something like this will work with curl


curl -X PUT 'http://ninja.test:8000/api/v1/clients/7N1aMAaWmp' \
-H "X-API-TOKEN:pXxKhsolfPBzbxprmo37oc9eHdA6VqZja5KruLL991z8hUkwYFlAHOrwqfh6VvuM" \
-H "Content-Type:application/json" \
-d '{"name":"Le Dudette","contacts":[{"id":"","first_name":"helly","email":"turbo124098@gmail.com"}]}' \
-H "X-Requested-With: XMLHttpRequest" \
-H "X-API-SECRET:password";

you’ll need to change the token / the url / and the hashed_id of the client to one of yours.

hey @david

I had a zoom call with the people at make, long story short, but it ended up being the way I formatted my api payload with the data from their system. The “created_at”:, updated_at": & “archived_at”: all needed to have the data placed in quotes. Very silly I know.

The only field that we could get to update is this one…
chrome_KWBzDysd77

It looks to be the “payment_terms”: however the data that make is pulling about the client does not contain anything with those wordings or values that I set.

Is there anyway you know of to get that value? Also the tricky part (hopefully not) is I need just that value returned. If I use a custom API HTTP request it gives me all the data for the client in one result. Which then I cant parse with make to get just that single value.

Any thoughts?

Thanks for all the support!

For anyone else that may run into this, this is my formatting for the HTTP request from make.com to my invoice Ninja… Of course you would need to put in your own API token for the X-API-TOKEN value and remap the fields in Request content to your own (all the {{#.xxxxx_xx}}) you see below…


-Request content

{
"id": "{{5.id}}",
"user_id": "{{5.user_id}}",
"assigned_user_id": "{{5.assigned_user_id}}",
"name": "{{5.name}}",
"website": "{{5.website}}",
"private_notes": "{{5.private_notes}}",
"balance": {{5.balance}},
"group_settings_id": "{{5.group_settings_id}}",
"paid_to_date": {{5.paid_to_date}},
"credit_balance": {{5.credit_balance}},
"last_login": {{5.last_login}},
"size_id": "{{5.size_id}}",	
"public_notes": "{{5.public_notes}}",
"client_hash": "{{5.client_hash}}",
"address1": "{{5.address1}}",
"address2": "{{5.address2}}",
"phone": "{{5.phone}}",
"city": "{{5.city}}",
"state": "{{5.state}}",
"postal_code": "{{5.postal_code}}",
"country_id": "{{5.country_id}}",
"industry_id": "{{5.industry_id}}",
"custom_value1": "{{5.custom_value1}}",
"custom_value2": "{{5.custom_value2}}",
"custom_value3": "{{2.id}}",
"custom_value4": "{{9.url}}",
"shipping_address1": "{{5.shipping_address1}}",
"shipping_address2": "{{5.shipping_address2}}",
"shipping_city": "{{5.shipping_city}}",
"shipping_state": "{{5.shipping_state}}",
"shipping_postal_code": "{{5.shipping_postal_code}}",
"shipping_country_id": "{{5.shipping_country_id}}",
"settings": {
"entity": "App\\Models\\Client",
"language_id": "{{5.settings.language_id}}",
"currency_id": "{{5.settings.currency_id}}",
"payment_terms": "{{5.settings.payment_terms}}",
"valid_until": "{{5.settings.valid_until}}",
"invoice_terms": "{{5.settings.invoice_terms}}",
"default_task_rate": {{5.settings.default_task_rate}},
"send_reminders": {{5.settings.send_reminders}}
},	
"is_deleted": {{5.is_deleted}},
"vat_number": "{{5.vat_number}}",
"id_number": "{{5.id_number}}",	
"updated_at": "{{5.updated_at}}",	
"archived_at": "{{5.archived_at}}",	
"created_at": "{{5.created_at}}",
"display_name": "{{5.name}}",
"number": "{{5.number}}",
"contacts":  [{
"id": "{{5.contacts[].id}}",
"first_name": "{{5.contacts[].first_name}}",
"last_name": "{{5.contacts[].last_name}}",
"email": "{{5.contacts[].email}}",
"created_at": "{{5.contacts[].created_at}}",
"updated_at": "{{5.contacts[].updated_at}}",
"archived_at": "{{5.contacts[].archived_at}}",
"is_primary": {{5.contacts[].is_primary}},
"is_locked": {{5.contacts[].is_locked}},
"phone": "{{5.contacts[].phone}}",			
"custom_value1": "{{5.contacts[].custom_value1}}",
"custom_value2": "{{5.contacts[].custom_value2}}",
"custom_value3": "{{5.contacts[].custom_value3}}",
"custom_value4": "{{5.contacts[].custom_value4}}",
"contact_key": "{{5.contacts[].contact_key}}",
"send_email": {{5.contacts[].send_email}},
"last_login": "{{5.contacts[].last_login}}",			
"password": "{{5.contacts[].password}}",
"link": "{{5.contacts[].link}}"
}
]
}