diff --git a/lib/Trello/Api/AbstractApi.php b/lib/Trello/Api/AbstractApi.php index 31e9f64..9906d11 100644 --- a/lib/Trello/Api/AbstractApi.php +++ b/lib/Trello/Api/AbstractApi.php @@ -36,6 +36,28 @@ abstract class AbstractApi implements ApiInterface */ public static $fields; + /** + * These are values that are being passed to Trello in our requests, that are not needed, + * and are causing Trello to give a "Error parsing body: too many parameters" error. + * + * @var array + */ + protected $ignore_on_update_fields = [ + 'actions', + 'board', + 'list', + 'attachments', + 'idLabels', + 'badges', + 'checklists', + 'stickers', + 'labels', + 'idChecklists', + 'members', + 'membersVoted', + 'descData', + ]; + /** * @param Client $client */ @@ -186,6 +208,8 @@ protected function postRaw($path, $body, $requestHeaders = array()) */ protected function patch($path, array $parameters = array(), $requestHeaders = array()) { + $parameters = $this->removeExcessParameters($parameters); + $response = $this->client->getHttpClient()->patch( $path, $this->createParametersBody($parameters), @@ -212,6 +236,8 @@ protected function put($path, array $parameters = array(), $requestHeaders = arr } } + $parameters = $this->removeExcessParameters($parameters); + $response = $this->client->getHttpClient()->put( $path, $this->createParametersBody($parameters), @@ -351,4 +377,23 @@ protected function validateAtLeastOneOf(array $atLeastOneOf, array $params) implode('", "', $atLeastOneOf) )); } + + /** + * Remove our fields that don't need to be passed to Trello. + * This prevents trello from throwing a "Error parsing body: too many parameters" error + * on requests with a card that has a lot of content. + * + * @param array $parameters + * + * @return array + */ + protected function removeExcessParameters($parameters) + { + // Remove our fields that don't need to be passed to Trello. + foreach($this->ignore_on_update_fields as $ignored_field) { + unset($parameters[$ignored_field]); + } + + return $parameters; + } }