Solved

Does anyone know how to retrieve a contact's BusinessCardKey through the API?

  • 8 May 2023
  • 8 replies
  • 105 views

Userlevel 2
Badge +1

thanks all, hope tax season wasn’t too fraught this year

 

pretty simple question!

 

I’m hoping to use the BusinessCard endpoint to both GET and PUT contacts’ BusinessCards but I can’t for the life of me find the contacts’ associated “BusinessCardKey” anywhere

 

doesn’t show up when I GET either all contacts or an individual contact with its ContactKey, so I dug a little deeper

 

the Expand System Query Function ($expand) indicated in the odata uri specifications is returning this error:

'{"error":{"code":"4002","message":"Query option \'Expand\' is not allowed. To allow it, set the \'AllowedQueryOptions\' property on EnableQueryAttribute or QueryValidationSettings."}}'

 

when I run this python GET with the requests library:

r = requests.get('https://api.karbonhq.com/v3/Contacts?$expand=BusinessCard', headers=ACCESS_HEADERS)

(where ACCESS_HEADERS is an object containing my AccessKey, Authorization, and contact-type values)

 

thanks again!

Mike

icon

Best answer by max 9 May 2023, 15:51

View original

8 replies

Userlevel 7
Badge +19

Hmm, interesting. Have you tried it on organizations?

EDIT: When I GET a contact, it returns their business cards with keys in an array without the ‘$expand’ parameter.

Userlevel 2
Badge +1

@max thank you, your timely response!

 

when I run

r = requests.get(f'https://api.karbonhq.com/v3/Contacts/{CONTACT_KEY}', headers=ACCESS_HEADERS)

 

I get this in response

{'@odata.context': 'https://api.karbonhq.com/v3/$metadata#Contacts/KarbonService.ContactDTO/$entity',
'@odata.type': '#KarbonService.ContactDTO',
'AccountingDetail': {'AnnualRevenue': None,
'BaseCurrency': None,
'BirthDate': None,
'ContactPermaKey': '4fHsJF1pDRrq',
'DeathDate': None,
'EntityType': None,
'FinancialYearEndDay': None,
'FinancialYearEndMonth': None,
'GstBasis': None,
'GstPeriod': None,
'IncomeTaxInstallmentPeriod': None,
'IncorporationDate': None,
'IncorporationState': None,
'IsVATRegistered': None,
'LegalName': None,
'LineOfBusiness': None,
'Notes': [],
'OrganizationPermaKey': None,
'OrganizationValuation': None,
'PaysTax': None,
'PrepareGST': None,
'ProvisionalTaxBasis': None,
'ProvisionalTaxRatio': None,
'RegistrationNumbers': [],
'RevenueModel': None,
'SalesTaxBasis': None,
'SalesTaxPeriod': None,
'Salutation': None,
'Sells': None,
'Sex': None,
'TaxCountryCode': 'US',
'TradingName': None},
'AvatarUrl': '/contacts/api/4vQylrFtl4X6/avatar/3a2fb6b3-2e97-471c-ae98-2272d2e1af8f',
'ClientManager': None,
'ClientOwner': -----------, #removing this intentionally
'ContactKey': '4fHsJF1pDRrq',
'ContactType': 'Client',
'EntityDescription': None,
'FirstName': 'Mike',
'LastModifiedDateTime': '2022-03-02T01:41:41Z',
'LastName': 'Richardson',
'MiddleName': '',
'PreferredName': 'Mike',
'RestrictionLevel': 'Public',
'Salutation': '',
'Suffix': '',
'UserDefinedIdentifier': None}

 

which is odd because the API Docs suggest I should get a list of BusinessCards with this request

Userlevel 7
Badge +19

Forgive the stupid question. :)

Does this contact have a business card attached?

Userlevel 2
Badge +1

yes!  

 

the contact is me and I have a business card with just my personal e-mail on it

Userlevel 7
Badge +19

Tomorrow I’ll send a loom of what I see when I run the GET. 

Userlevel 7
Badge +19

Hey @Mike Richardson, I was wrong about the GET parameters. I didn’t realize that I had business cards expanded by default. Try this:

https://api.karbonhq.com/v3/Contacts/[Contactkey]?$expand=BusinessCards

Here’s the response:

{
"@odata.context": "https://api.karbonhq.com/v3/$metadata#Contacts/KarbonService.ContactDTO(BusinessCards())/$entity",
"@odata.type": "#KarbonService.ContactDTO",
"ContactKey": "2PQtTP5p1Trj",
"FirstName": "Testing",
"MiddleName": "",
"LastName": "Tester",
"PreferredName": "Testing",
"Salutation": null,
"Suffix": null,
"ClientOwner": null,
"ClientManager": null,
"ContactType": null,
"UserDefinedIdentifier": null,
"RestrictionLevel": "Public",
"AvatarUrl": null,
"LastModifiedDateTime": "2023-05-09T13:45:22Z",
"EntityDescription": {
"Text": null
},
"AccountingDetail": {
"ContactPermaKey": "2PQtTP5p1Trj",
"OrganizationPermaKey": null,
"BirthDate": null,
"DeathDate": null,
"Salutation": null,
"Sex": null,
"FinancialYearEndDay": null,
"FinancialYearEndMonth": null,
"IncorporationDate": null,
"IncorporationState": null,
"LegalName": null,
"LineOfBusiness": null,
"EntityType": null,
"TaxCountryCode": "US",
"TradingName": null,
"AnnualRevenue": null,
"BaseCurrency": null,
"GstBasis": null,
"GstPeriod": null,
"IncomeTaxInstallmentPeriod": null,
"IsVATRegistered": null,
"OrganizationValuation": null,
"PaysTax": null,
"PrepareGST": null,
"ProvisionalTaxBasis": null,
"ProvisionalTaxRatio": null,
"RevenueModel": null,
"SalesTaxBasis": null,
"SalesTaxPeriod": null,
"Sells": null,
"RegistrationNumbers": [],
"Notes": []
},
"BusinessCards": [
{
"BusinessCardKey": "mFWxlPmc4bG",
"EntityType": "Contact",
"EntityKey": "2PQtTP5p1Trj",
"IsPrimaryCard": true,
"WebSites": [],
"EmailAddresses": [
"[email removed]"
],
"OrganizationKey": "4mmd2qnswqBx",
"RoleOrTitle": null,
"FacebookLink": null,
"LinkedInLink": null,
"TwitterLink": null,
"SkypeLink": null,
"Addresses": [],
"PhoneNumbers": []
}
]
}

 

Userlevel 3
Badge +2

This works for me:
 


 

I’ve found in the past there is some funkiness around the expand function when I copy a section but if I restart that section it usually works.

Userlevel 2
Badge +1

@max @Automation n Stuff yes!

 

thank you so much for your help with this, completely solved my problem

Reply