Adding Contact through API - V3

SOLVED
Go to solution
CarolynG105
Campaign Collaborator

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 ACCEPTED SOLUTION
raleighb3
Marketing Legend

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"
}

View solution in original post

1 REPLY 1
raleighb3
Marketing Legend

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"
}

Resources
Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Announcements

API Updates

Join our list to be notified of new features and updates to our V3 API.

Sign Up