Status code 405 on Updating Deal, yet not on Creating



I’m having an issue with the “Update deal” method of the API. Without any error response, I’m getting a 405 Status Code and I’m unable to update a deal.

As far as I can tell, I don’t find any syntaxis errors on the JSON nor I’m sending incorrect data for each property. In fact I tried to send each property individually and I’m getting the same result.

Also I succesfully created a Deal with this same JSON (adding associations and changing the endpoint of course), however updating always gives me the same status code.

I have not had any issues with other methods such as Update Contact, Get all Deals, Get All Contacts, Create Deal, etc.

I’ll appreciate your help, thanks!

PHP code used:

$post_json = '
	"properties": [
			"value": "contractsent",
			"name": "dealstage"
			"value": "default",
			"name": "pipeline"
			"value": 150162347327,
			"name": "closedate"
			"value": "570",
			"name": "amount"
			"value": 63234,
			"name": "id_venta"
			"value": "Cerrado con ID de alumno 12843 y ID de venta 63234 en ERP. MUY BUENA OFERTA.",
			"name": "closed_won_reason"
$endpoint = '';
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $post_json);
@curl_setopt($ch, CURLOPT_URL,        $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response    = curl_exec($ch);
$status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curl_errors = curl_error($ch);
if( !empty($curl_errors) || $status_code!=204 ){
    $errors = true;
    echo "
    <li>Curl Errors: " .$curl_errors ."</li>
	<li>Status code: " .$status_code ."</li>
	<li>Response:    " .$response    ."</li>
	<i>Endpoint:     " .$endpoint    ."</li>
	<li>Data sent:   " .$post_json   ."</li>

Results I get from the PHP;


Hi @MrClick,

Thanks for the detailed note, the status code 405 means the method is not allowed for that endpoint. For this line @curl_setopt($ch, CURLOPT_POST, true); you should instead use url_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); Essentially you are making a POST request when you need to be making a PUT request.

I’m not a PHP expert but based on some quick googling that should do the trick.



Thank you very much Zack, this solved my problem.

Regards and have a nice day!