Home Forums Support Update contact CURL

This topic contains 4 replies, has 2 voices, and was last updated by  andrew1810 1 week, 5 days ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #23173

    andrew1810
    Participant

    I have my CURL working to update the client details, but when I include the contact details, it is creating a new blank contact and marking the old one as deleted

    This is how the CURL code looks:
    {"id":"1","name":"test2 test2","address1":"my house","city":"my city","state":"my state","postal_code":"12345","work_phone":"myphone","contacts":[{"id":1,"first_name":"test2","last_name":"test2","email":"[email protected]","phone":"myphone"}]}

    #23179

    Hillel Coren
    Keymaster

    I’m not sure, that looks ok to me?

    Note: if you’re comparing to the database the API id uses the public_id field not the id field.

    #23181

    andrew1810
    Participant

    Thank you, so which ID should I give for the contacts, the one for the client? I wonder if I’m giving it the wrong ID

    #23183

    Hillel Coren
    Keymaster

    Contacts have their own id, you can use the /clients GET request to load the client and contacts.

    #23184

    andrew1810
    Participant

    The ID seems right, when I run this on a terminal I get illegal port number and “curl: (3) [globbing] bad range specification in column 38”

    Then it updates the client and blanks the contact details (it also increments the contact id)

    curl -X PUT https://mywebsite/api/v1/clients/1 -H "X-Ninja-Token: mytoken" -H 'X-Requested-With: XMLHttpRequest'-H 'Content-Type: application/json' -d "
    {"id":"1","name":"test2 test2","address1":"my house","city":"my city","state":"my state","postal_code":"12345","work_phone":"0489393","contacts":[{"id":36,"first_name":"test2","last_name":"test2","email":"[email protected]","phone":"023322"}]}" --insecure
Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

Posted in: