I am working with the Planning Center API, it was built to conform to the JSON API 1.0 specification.
We are needing to post a persons data to Planning center. The API seems to break up a person, from their phone number and email. I am new to working with the this so I am not sure if you can post them all in the same cURL request, or if I would need 3 requests. My understanding (possibly misguided) is that I can "include" the email and phone number in the POST request.
This is what I have:
$person = '{
"data": {
"type": "Person",
"attributes": {
"first_name": "Test",
"last_name": "User"
},
"relationships": {
"primary_campus": {
"data": { "type": "PrimaryCampus", "id": "123" }
}
}
},
"include":{
"data": {
"type": "emails",
"attributes": {"address": "test@test.com"}
}
}
}';
$channel = curl_init();
curl_setopt( $channel, CURLOPT_URL, "https://api.planningcenteronline.com/people/v2/people" );
//curl_setopt( $channel, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $channel, CURLOPT_USERPWD, $application_ID.":".$application_secret );
curl_setopt( $channel, CURLOPT_POST, true);
curl_setopt( $channel, CURLOPT_POSTFIELDS, $person);
curl_exec($channel);
echo $channel;
This only seems to create the persons First name and last name (and associated campus). The email is not created.
Here is the documentation for the email. Here is the documentation for the person.
Any ideas what I am missing here?
JSON API Specification v1.0 does not support bulk creation. If this specific API does not implement additional functionality that's not part of JSON API specification, you can't create a person with it's associated email in only one request.
Side note: This will likely be supported by upcoming v1.1 version trough a feature called Operations. You can find more details in this pending pull request.
So to put it short: As far as I got their specific implementation you have to create a person with first request and then create an email address associated to it with another request.