Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create company - Bad Request #47

Closed
obayesshelton opened this issue May 27, 2016 · 2 comments
Closed

Create company - Bad Request #47

obayesshelton opened this issue May 27, 2016 · 2 comments

Comments

@obayesshelton
Copy link

Hi,

I'm using version 0.9.0

With the following code

$hubspot = \Fungku\HubSpot\HubSpotService::make('**KEY**');
$company = $hubspot->companies()->create(
array(
    array(
        'property' => 'name',
        'value' => 'Hello'
    ),
    array(
        'property' => 'description',
        'value' => 'World'
    )
));

I get the following error

object(Fungku\HubSpot\Http\Response)#119 (2) {
  ["response":protected]=>
  object(GuzzleHttp\Psr7\Response)#123 (6) {
    ["reasonPhrase":"GuzzleHttp\Psr7\Response":private]=>
    string(11) "Bad Request"
    ["statusCode":"GuzzleHttp\Psr7\Response":private]=>
    int(400)
    ["headers":"GuzzleHttp\Psr7\Response":private]=>
    array(5) {
      ["access-control-allow-credentials"]=>
      array(1) {
        [0]=>
        string(5) "false"
      }
      ["content-type"]=>
      array(1) {
        [0]=>
        string(31) "application/json; charset=UTF-8"
      }
      ["content-length"]=>
      array(1) {
        [0]=>
        string(3) "291"
      }
      ["date"]=>
      array(1) {
        [0]=>
        string(29) "Fri, 27 May 2016 13:11:26 GMT"
      }
      ["connection"]=>
      array(1) {
        [0]=>
        string(5) "close"
      }
    }
    ["headerLines":"GuzzleHttp\Psr7\Response":private]=>
    array(5) {
      ["Access-Control-Allow-Credentials"]=>
      array(1) {
        [0]=>
        string(5) "false"
      }
      ["Content-Type"]=>
      array(1) {
        [0]=>
        string(31) "application/json; charset=UTF-8"
      }
      ["Content-Length"]=>
      array(1) {
        [0]=>
        string(3) "291"
      }
      ["Date"]=>
      array(1) {
        [0]=>
        string(29) "Fri, 27 May 2016 13:11:26 GMT"
      }
      ["Connection"]=>
      array(1) {
        [0]=>
        string(5) "close"
      }
    }
    ["protocol":"GuzzleHttp\Psr7\Response":private]=>
    string(3) "1.1"
    ["stream":"GuzzleHttp\Psr7\Response":private]=>
    object(GuzzleHttp\Psr7\Stream)#125 (7) {
      ["stream":"GuzzleHttp\Psr7\Stream":private]=>
      resource(13) of type (stream)
      ["size":"GuzzleHttp\Psr7\Stream":private]=>
      int(291)
      ["seekable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["readable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["writable":"GuzzleHttp\Psr7\Stream":private]=>
      bool(true)
      ["uri":"GuzzleHttp\Psr7\Stream":private]=>
      string(10) "php://temp"
      ["customMetadata":"GuzzleHttp\Psr7\Stream":private]=>
      array(0) {
      }
    }
  }
  ["data":protected]=>
  object(stdClass)#124 (5) {
    ["status"]=>
    string(5) "error"
    ["message"]=>
    string(30) "Property values were not valid"
    ["correlationId"]=>
    string(36) "4bd79dc4-90b1-4f15-ba3a-f794dac68de3"
    ["validationResults"]=>
    array(1) {
      [0]=>
      object(stdClass)#121 (4) {
        ["isValid"]=>
        bool(false)
        ["message"]=>
        string(24) "duplicate property value"
        ["error"]=>
        string(26) "DUPLICATE_PROPERTY_TO_SAVE"
        ["name"]=>
        string(0) ""
      }
    }
    ["requestId"]=>
    string(36) "2af2576e-f903-414a-a8ab-021a93468a7a"
  }
}

@ryanwinchester
Copy link
Collaborator

ryanwinchester commented May 27, 2016

@obayesshelton the key you have as property should be name

$hubspot = \Fungku\HubSpot\HubSpotService::make('**KEY**');
$company = $hubspot->companies()->create([
    [
        'name' => 'name',
        'value' => 'Hello',
    ],
    [
        'name' => 'description',
        'value' => 'World',
    ],
]);

see: http://developers.hubspot.com/docs/methods/companies/create_company

@obayesshelton
Copy link
Author

My bad, sorry :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants