Bobrot 0 Posted January 24, 2015 Report Share Posted January 24, 2015 Hi Everyone, I'm not new to development, but I'm new to PHP and cURL. I'm just working on a project for a friend, attempting to tie his website to his CRM. I'm getting a 415 from a basic api request and I'm guessing someone can probably take one look at this code and tell me what I'm missing. Any help would be appreciated. ThanksRobert $curl = curl_init(); curl_setopt($curl, CURLOPT_HTTPHEADER, "Content-Type: application/json; charset=utf-8"); curl_setopt($curl, CURLOPT_HEADER, 1); curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_URL, $baseUrl . "Opportunity"); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncodedContent); $response = curl_exec($curl); if( $response === false) { echo 'Curl error: ' . curl_error($curl); } else { echo $response; } Quote Link to post Share on other sites
that0n3guy 49 Posted January 26, 2015 Report Share Posted January 26, 2015 I personally avoid using curl (by it self) at all costs . I would use any of the php packages out there that help w/ consuming API's:https://github.com/guzzle/guzzle... there are a bunch out there... but guzzle is the only one I can think of at the moment. Quote Link to post Share on other sites
mfoote 2 Posted March 2, 2015 Report Share Posted March 2, 2015 Maybe you already figured this out but http://wiki.x2engine.com/wiki/REST_API_Referencedo a find on 415 I used the following and that error went away for me:curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json; charset=utf-8;")); Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.