Skip to content

Instantly share code, notes, and snippets.

@cursedcoder
Created November 16, 2013 22:38
Show Gist options
  • Save cursedcoder/7506314 to your computer and use it in GitHub Desktop.
Save cursedcoder/7506314 to your computer and use it in GitHub Desktop.
diff --git a/lib/Github/Api/Repository/Assets.php b/lib/Github/Api/Repository/Assets.php
index ad48aaf..cee57d5 100644
--- a/lib/Github/Api/Repository/Assets.php
+++ b/lib/Github/Api/Repository/Assets.php
@@ -74,7 +74,6 @@ class Assets extends AbstractApi
}
$name = $params['name'];
- $parameters['body'] = $params['body'];
$headers['Content-Type'] = $params['content-type'];
// Asset creation requires a separate endpoint, uploads.github.com.
@@ -83,7 +82,15 @@ class Assets extends AbstractApi
$baseUrl = $this->client->getHttpClient()->client->getBaseUrl();
$this->client->getHttpClient()->client->setBaseUrl('https://uploads.github.com/');
- $response = $this->post('repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/releases/'.rawurlencode($id).'/assets?name='. $name, $parameters, $headers);
+ $apiPath = sprintf(
+ 'repos/%s/%s/releaeses/%s/assets?name=%s',
+ rawurlencode($username),
+ rawurlencode($repository),
+ rawurlencode($id),
+ $name
+ );
+
+ $response = $this->post($apiPath, array('body' => $params['body']), $headers);
// Reset the base url.
$this->client->getHttpClient()->client->setBaseUrl($baseUrl);
diff --git a/lib/Github/HttpClient/HttpClient.php b/lib/Github/HttpClient/HttpClient.php
index 88c2b25..1ab0631 100644
--- a/lib/Github/HttpClient/HttpClient.php
+++ b/lib/Github/HttpClient/HttpClient.php
@@ -173,9 +173,14 @@ class HttpClient implements HttpClientInterface
protected function createRequest($httpMethod, $path, array $parameters = array(), array $headers = array())
{
if ('GET' !== $httpMethod) {
- $requestBody = count($parameters) === 0
- ? null : json_encode($parameters, empty($parameters) ? JSON_FORCE_OBJECT : 0)
- ;
+ if (1 === count($parameters) && isset($parameters['body'])) {
+ $requestBody = $parameters['body'];
+ } else {
+ $requestBody = count($parameters) === 0
+ ? null : json_encode($parameters, empty($parameters) ? JSON_FORCE_OBJECT : 0)
+ ;
+ }
+
$options = array();
} else {
$requestBody = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment