I am trying to use outreach API for my PHP website. On outreach, this is request they mentioned:
POST https://api.outreach.io/api/v2/prospects
{ "data": { "attributes": { "firstName": "Test_3", "lastName": "API" }, "type": "prospect" } }
In PHP , i converted this to following code but it gives error "Bad Request". Please help me what i am doing wrong, accessToken in below code is having correct value.
$urlCreateAccount = "https://api.outreach.io/api/v2/prospects";
$attributes = array("firstName"=> "Sally","lastName"=> "Biu");
$paramsCreateAccount = "type=prospect$attributes=".$attributes;
$headr[] = "Authorization:bearer $accessToken";
$curl = curl_init($urlCreateAccount);
curl_setopt($curl, CURLOPT_HTTPHEADER,$headr);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $paramsCreateAccount);
$jsonResponseCreateAccount = curl_exec($curl);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);