REST - Create a contact

I’m trying to use POSTMAN to test out creating a new customer contact with REST.
This is the API url (I found from another post about creating a customer contact): https://XXXXXX/E10Train/api/v1/Erp.BO.CustCntSvc/CustCnts

I keep getting The request is invalid. Here is dummy test I’m sending with POSTMAN:

  {
  "Company": "SD",
  "CustNum": 440,
  "ShipToNum": "",
  "Name": "ABC",
  "Func": "test",
  "FaxNum": "6666",
  "PhoneNum": "7777",
  "EMailAddress": "w@example.com",
  "SpecialAddress": 0,
  "SFPortalPassword": "password123",
  "SFUser": 0,
  "PortalUser": 0,
  "RoleCode": "",
  "CellPhoneNum": "",
  "PagerNum": "",
  "HomeNum": "",
  "AltNum": "",
  "ContactTitle": "",
  "ReportsTo": "",
  "Inactive": 0,
  "FirstName": "A",
  "MiddleName": "B",
  "LastName": "C",
  "Prefix": "",
  "Suffix": "",
  "Initials": "ABC",
  "ExternalID": "",
  "GlobalLock": 1,
  "ShowInputPrice": 1,
  "ChangeTime": 0,
  "ChangedBy": "",
  "MasterCustNum": 0,
  "MasterShipToNum": "",
  "MasterConNum": 0,
  "PerConID": 0,
  "SyncNameToPerCon": 0,
  "SyncAddressToPerCon": 0,
  "SyncPhoneToPerCon": 0,
  "SyncEmailToPerCon": 0,
  "SyncLinksToPerCon": 0,
  "PerConAddress": 0,
  "SysRevID": "",
  "SysRowID": "",
  "SyncToExternalCRM": 1,
  "ExternalCRMCustomerID": "",
  "ExternalCRMContactID": "",
  "RoleDescription": "",
  "PrimaryBilling": 1,
  "PrimaryPurchasing": 1,
  "PrimaryShipping": 1,
  "GlbFlag": 1,
  "AttrCodeList": "",
  "GlbLink": "",
  "ContactName": "ABC",
  "PerConName": "",
  "BitFlag": 0,
  "CustNumName": "",
  "CustNumBTName": "",
  "CustNumCustID": "",
  "MasterCustNumBTName": "",
  "MasterCustNumName": "",
  "MasterCustNumCustID": "",
  "RowMod": ""
}

The swagger documentation says that everything is optional. I don’t think that’s accurate. I’ve been playing around with adding and removing fields but have not sure where I can start to troubleshoot because here’s my POSTMAN response from the API:
image

If I want the system to create a new record, what should I put for sys-row-id and customer contact number? Should they be left blank? Should they not even be in the request?

How does your import compare to the Trace?

I’m not sure why it wasn’t working but I was able to get it working after following the trace of a simple contact where I only input the name.

Here are some takeaways I learned for anyone else wanting to do this:

  • If you want the system to assign a field leave it out of the payload
  • If you have UD Fields you can just reference them without having to include any UD SysRow IDs.
  • If you leave RowMod out it seems to choose the right mod based on the presence of PerConID and ConNum

This is the minimum JSON REST payload I was able to use to create a new customer contact:

{
  "Company": "SD",
  "CustNum": 440,
  "Name": "Mr. Test"
}

Now, it’s just a matter of adding extra detail fields to the payload as we see fit on our custom web page.

Also here’s the minimum JSON REST payload needed to update:

{
 "Company": "SD",
 "CustNum": 440,
 "Name": "Mr. Test", 
 "ConNum": 1,   
 "PerConID": 11842    
}

And to delete a contact:

{
“Company”: “SD”,
“CustNum”: 440,
“Name”: “Mr. Test”,
“ConNum”: 1,
“PerConID”: 11842,
“RowMod” : “D”
}

Maybe this could help someone in a similar situation.

5 Likes