Community
Showing results for 
Search instead for 
Do you mean 
Reply

Updating Custom Fields via the API

Accepted Solution Solved
Copper Super Contributor
Posts: 41
Country: USA
Accepted Solution

Updating Custom Fields via the API

 

the newest  Act!  Web APi supports custom fields: Yahoo!  

 

We can get a list of the custom fields. 

We  can read data in them, but cannot write it.

 

Reading one record and writing some of the same data back as an update fails with an Error 500

 

Here is the situation:

 

  1. API version 1.0.138.0
  2. Step 1: Request data from the demo database using the following URL: http://vmact17/Act.Web.API/api/Contacts .  Here is the JSON I am getting for a particular record (extracted from the list):

 

{

    "id": "bd398c71-111f-48c2-a350-021ea757ecb3",

    "idStatus": "Customer",

    "isUser": false,

    "company": "A1 Services-US Operations",

    "department": null,

    "companyID": "",

    "contactType": "Contact",

    "firstName": "Amanda",

    "lastName": "Form",

    "lastResults": null,

    "messengerID": null,

    "middleName": null,

    "nameSuffix": null,

    "namePrefix": null,

    "fullName": "Amanda Form",

    "referredBy": null,

    "salutation": "Amanda",

    "jobTitle": "VP of Sales",

    "emailAddress": null,

    "altEmailAddress": null,

    "personalEmailAddress": null,

    "businessPhone": "(212) 546-7890",

    "businessExtension": null,

    "mobilePhone": null,

    "mobileExtension": null,

    "homePhone": null,

    "homeExtension": null,

    "website": null,

    "birthday": "1969-10-02T00:00:00-05:00",

    "businessAddress": {

      "line1": "2131 W. Tiny Rd.",

      "line2": null,

      "line3": null,

      "city": "New York",

      "state": "NY",

      "postalCode": "20122",

      "country": "United States"

    },

    "homeAddress": {

      "line1": null,

      "line2": null,

      "line3": null,

      "city": null,

      "state": null,

      "postalCode": null,

      "country": null

    },

    "pagerPhone": null,

    "pagerExtension": null,

    "faxPhone": null,

    "faxExtension": null,

    "alternatePhone": null,

    "alternateExtension": null,

    "customFields": {

      "last yrs purchases": null,

      "children names": null,

      "user10": null,

      "spouse": null,

      "anniversary": null,

      "pet names": null,

      "has pets": "False",

      "email permission": null,

      "user7": null,

      "user6": null,

      "user5": null,

      "user4": null,

      "user3": null,

      "user2": null,

      "user1": null,

      "spouse interests": null,

      "user8": null,

      "first purchase": null,

      "spouse employer": null,

      "risk": null,

      "motivation": null,

      "photo": null,

      "key contact": "False",

      "trivia": null,

      "clubs associations": null,

      "hobbies": null,

      "customer id": null,

      "has children": "False",

      "user9": null,

      "map reference": null,

      "blog": null,

      "special instructions": null

    },

    "created": "2005-06-27T16:26:17-05:00",

    "edited": "2016-03-17T22:07:11-05:00",

    "editedBy": "Chris Huffman",

    "recordOwner": "Chris Huffman"

  }

 

  1. Step 2: Through our objects, reflect back same record with exception we are sending only fields with data (with exception of removing CreatedDate, EditDate, EditedBy fields):
    1. URL: http://vmact17/ACT.Web.API/api/Contacts/bd398c71-111f-48c2-a350-021ea757ecb3
    2. Method: PUT
    3. JSON:

{

  "FirstName": "Amanda",

  "LastName": "Form",

  "Salutation": "Amanda",

  "Company": "A1 Services-US Operations",

  "CompanyId": "",

  "JobTitle": "VP of Sales",

  "BusinessPhone": "(212) 546-7890",

  "BusinessAddress": {

    "Line1": "2131 W. Tiny Rd.",

    "City": "New York",

    "State": "NY",

    "PostalCode": "20122",

    "Country": "United States"

  },

  "HomeAddress": {},

  "Birthday": "1969-10-02T00:00:00",

  "IdStatus": "Customer",

  "ContactType": "Contact",

  "Id": "bd398c71-111f-48c2-a350-021ea757ecb3",

  "RecordOwner": "Chris Huffman"

}

 

  1. We received the status 500:

System.Net.WebException: The remote server returned an error: (500) Internal Server Error.

   at System.Net.HttpWebRequest.GetResponse()

 

 

Alan Lee

www.OAKMerge.com 

Import/ Export Utility for Act!

 


Accepted Solutions
Highlighted
Solution
Accepted by topic author alanmlee
‎03-13-2017 02:30 PM
Employee
Posts: 215
Country: USA

Re: Updating Custom Fields via the API

Hi Alan,

 

I see i few issues off the bat:

 

- PUT is not a partial update, but a full update.  Hence, you need to pass all of the fields in the PUT request JSON body, otherwise you are effectively going to overwrite fields that you are not passing with NULL.  We'll be adding partial updates (via PATCH) in the future.

- I'm not sure why you have a empty {} for HomeAddress

- ContactType can't be changed

 

Granted we should not be failing with a 500 here, but a 400 with details.

 

Hope that gets you further,

--Xavier

View solution in original post


All Replies
Highlighted
Solution
Accepted by topic author alanmlee
‎03-13-2017 02:30 PM
Employee
Posts: 215
Country: USA

Re: Updating Custom Fields via the API

Hi Alan,

 

I see i few issues off the bat:

 

- PUT is not a partial update, but a full update.  Hence, you need to pass all of the fields in the PUT request JSON body, otherwise you are effectively going to overwrite fields that you are not passing with NULL.  We'll be adding partial updates (via PATCH) in the future.

- I'm not sure why you have a empty {} for HomeAddress

- ContactType can't be changed

 

Granted we should not be failing with a 500 here, but a 400 with details.

 

Hope that gets you further,

--Xavier