zendesk / zendesk_api_client_php

Official Zendesk API v2 client library for PHP
336 stars 259 forks source link

Adding user to organization fails with 422 #353

Closed DerManoMann closed 7 years ago

DerManoMann commented 7 years ago

Hi there, I am trying to add a user to an organization as per https://developer.zendesk.com/rest_api/docs/core/organization_memberships#create-membership

However, I am getting a `422 Unprocessable Entity back from the API with these details:

{"error":"RecordInvalid","description":"Record validation errors","details":{"organization":[{"description":"Organizatio (truncated...)
 [details] {"error":"RecordInvalid","description":"Record validation errors","details":{"organization":[{"description":"Organization cannot be blank","error":"BlankValue"}]}}

Here are the relevant bits of my code:

$client = new ZendeskClient($subdomain);
$client->setAuth(Auth::BASIC, ['username' => $username, 'token' => $token]);

    $org = $client->users(123)->organizationMemberships()->create([
        'user_id' => 123,
        'organization_id' => 456,
    ]);

The API user (123) has admin rights and organization_id 456 does exist.

DerManoMann commented 7 years ago

nvm - confused id and organization_id