Keep getting "403 Forbidden" when using PUT commands

Hi,

I seem to be able to make POST and GET requests fine but whenever I make a
PUT request I’m getting 403 Forbidden returned.

I’m using Zend Framework so not sure if there’s an error with their
implementation or if I’m overlooking something. Was hoping someone here may
be able to help.

The code I’m running:

public function testCurlPut() {
    $uri = 'https://api.sandbox.freeagent.com/v2/invoices/<CORRECT_ID>

/transitions/mark_as_draft’;

    $adapter = new Zend_Http_Client_Adapter_Curl();
    $adapter->setConfig(array(
        "curloptions" => array(
            CURLOPT_SSL_VERIFYHOST => 0,
            CURLOPT_SSL_VERIFYPEER => 0,
            CURLOPT_HEADER => 1,
            CURLOPT_VERBOSE => 1,
            CURLOPT_RETURNTRANSFER => 1
        )
    ));

    $client = new Zend_Http_Client();
    $client->setAdapter($adapter);

    //Contact returns as a URL not an ID so we're going to always pass 

$this->url in and not concat here.
$client->setUri($uri);

    $accessToken = "<ACCESS_TOKEN>";

    $client->setHeaders(
        array(
            "Authorization: Bearer ". $accessToken,
            "Accept: application/json",
            "Content-type: application/json",
        )
    );

    $client->request("PUT");

    var_dump($client->getLastRequest());
    var_dump($client->getLastResponse());

    exit;
}

The output of the code:

string(316) "PUT /v2/invoices/<CORRECT_ID>/transitions/mark_as_draft
HTTP/1.1
Host: api.sandbox.freeagent.com
Connection: close
Accept-encoding: gzip, deflate
User-Agent: Zend_Http_Client
Authorization: Bearer <ACCESS_TOKEN>
Accept: application/json
Content-type: application/json
Content-Length: 0

"object(Zend_Http_Response)#122 (5) { [“version”:protected]=> string(3)
“1.1” [“code”:protected]=> int(403) [“message”:protected]=> string(9)
“Forbidden” [“headers”:protected]=> array(11) { [“Server”]=>
string(11) “nginx/1.4.1” [“Date”]=> string(29) “Thu, 07 Nov 2013
10:35:42 GMT” [“Content-type”]=> string(31) “application/json;
charset=utf-8” [“Connection”]=> string(5) “close” [“Status”]=>
string(13) “403 Forbidden” [“X-ua-compatible”]=> string(16)
“IE=Edge,chrome=1” [“Cache-control”]=> string(8) “no-cache”
[“X-request-id”]=> string(32) “eed797f78f9933b4801b44d3c9ea6c4c”
[“X-runtime”]=> string(8) “0.098295” [“X-rev”]=> string(7)
“a0ff5a3” [“X-host”]=> string(4) “web1” } [“body”:protected]=> string(1) " "
}

Thanks

Seems that the transitions to set to marked and scheduled are the causes.

I’ve just updated my code for the PUT to update the invoice itself and as
long as you use Zend_Http_Client::setRawData to send your JSON it works.

Seems that the transitions to set to marked and scheduled are the causes.

I’ve just updated my code for the PUT to update the invoice itself and as
long as you use Zend_Http_Client::setRawData to send your JSON it works.