cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Contact through API - V3

SOLVED
Occasional Contributor

Adding Contact through API - V3

How would I format the JSON, if I only want to add the EmailAddress, FirstName and LastName?  I want to make all the other fields blank or not even added them, if possible.

I keep getting a 400 error Bad request, if I do not supply all the fields.

 

string content =
"{\"email_address\" : {"
+ "\"address\" : \"" + emailAddress + "\", "
+ "\"permission_to_send\" : \"implicit\""
+ "}, "
+ "\"first_name\" : \"" + firstName + "\", "
+ "\"last_name\" : \"" + lastName + "\", "
+ "\"job_title\" : \"test\", "
+ "\"company_name\" : \"tst\", "
+ "\"create_source\" : \"Account\", "
+ "\"birthday_month\" : 11, "
+ "\"birthday_day\" : 11, "
+ "\"anniversary\" : \"2006-11-15\", "
+ "\"steet_addresses\" : {"
+ "\"kind\": \"home\", "
+ "\"street\" : \"1221 Robinson Road\", "
+ "\"city\" : \"Houston\", "
+ "\"state\" : \"Texas\", "
+ "\"country\" : \"United States\", "
+ "} }";

 

 

This string does not work.  I always get an error.

string content2 =
"{\"email_address\" : {"
+ "\"address\" : \"" + emailAddress + "\", "
+ "\"permission_to_send\" : \"implicit\""
+ "}, "
+ "\"first_name\" : \"" + firstName + "\", "
+ "\"last_name\" : \"" + lastName + "\", "
+ "\"job_title\" : \"\", "
+ "\"company_name\" : \"\", "
+ "\"create_source\" : \"Account\", "
+ "\"birthday_month\" : , "
+ "\"birthday_day\" : , "
+ "\"anniversary\" : \"\", "
+ "\"steet_addresses\" : {"
+ "\"kind\": \"\", "
+ "\"street\" : \"\", "
+ "\"city\" : \"\", "
+ "\"state\" : \"\", "
+ "\"country\" : \"\", "
+ "} }";

1 REPLY 1
Highlighted
Advisor

Re: Adding Contact through API - V3

if getting that 400 error, then request is not formatted correctly.  Do you have/use Postman?  very valuable tool for testing Requests, among other things.  link:  https://www.getpostman.com/

 

example for adding contact:

{
"email_address": {
"address": "ddipper@hotmail.com",
"permission_to_send": "implicit"
},
"first_name": "Dipali",
"last_name": "Nipperdipper" ,
"create_source": "Contact"
}