zendesk / zendesk_api_client_rb

Official Ruby Zendesk API Client
http://developer.zendesk.com/
Apache License 2.0
387 stars 183 forks source link

problem creating organizations via API #494

Closed rsl closed 1 year ago

rsl commented 2 years ago

hello. im trying to use the gem to create organizations but hitting a 403 issue i don't understand. i've put the output of console below to provide any context needed hopefully. but basically, i'm an admin user and should have rights to create an organization. you can see the role in the response to client.current_user.to_hash and you can see i can fetch organizations fine via client.organizations.first but when i try to create the most basic of organizations... boom. thanks for your help.

irb(main):001:1* client ||= ZendeskAPI::Client.new do |config|
irb(main):002:1*   config.url = ENV['ZENDESK_API_HOST'] + '/api/v2'
irb(main):003:1*   config.username = ENV['ZENDESK_API_USERNAME']
irb(main):004:1*   config.token = ENV['ZENDESK_API_TOKEN']
irb(main):005:1*   config.retry = true
irb(main):006:0> end
=> 
#<ZendeskAPI::Client:0x000000010e82f258
...
irb(main):008:0> client.current_user.to_hash
=> 
{"id"=>0, # [redacted]
 "url"=>"[redacted]",
 "name"=>"[redacted]",
 "email"=>"[redacted]",
 "created_at"=>2019-11-12 18:26:11 UTC,
 "updated_at"=>2022-05-11 14:29:10 UTC,
 "time_zone"=>"Eastern Time (US & Canada)",
 "iana_time_zone"=>"America/New_York",
 "phone"=>nil,
 "shared_phone_number"=>nil,
 "photo"=>nil,
 "locale_id"=>1,
 "locale"=>"en-US",
 "organization_id"=>[redacted],
 "role"=>"admin",
 "verified"=>true,
 "authenticity_token"=>"[redacted]",
 "external_id"=>nil,
 "tags"=>[],
 "alias"=>nil,
 "active"=>true,
 "shared"=>false,
 "shared_agent"=>false,
 "last_login_at"=>2022-05-11 14:24:44 UTC,
 "two_factor_auth_enabled"=>nil,
 "signature"=>nil,
 "details"=>nil,
 "notes"=>nil,
 "role_type"=>4,
 "custom_role_id"=>1500007042401,
 "moderator"=>true,
 "ticket_restriction"=>nil,
 "only_private_comments"=>false,
 "restricted_agent"=>false,
 "suspended"=>false,
 "default_group_id"=>360007039253,
 "report_csv"=>true,
 "user_fields"=>{},
 "role_id"=>"admin"}
irb(main):010:0> puts client.organizations.first
organization: #<ZendeskAPI::Trackie created_at=2019-11-12 18:26:11 UTC details=nil domain_names=#<Hashie::Array []> external_id=nil group_id=nil id=370286388413 name="Fractured Atlas" notes=nil organization_fields=#<ZendeskAPI::Trackie> shared_comments=false shared_tickets=false tags=#<Hashie::Array []> updated_at=2019-11-12 18:26:14 UTC url="https://fracturedatlasqa.zendesk.com/api/v2/organizations/370286388413.json">
=> nil
irb(main):011:0> 
irb(main):012:0> puts client.organizations.create!(name: 'testing')
/Users/rsl/.gem/ruby/3.1.2/gems/zendesk_api-1.35.0/lib/zendesk_api/middleware/response/raise_error.rb:20:in `on_complete': the server responded with status 403 -- post https://fracturedatlasqa.zendesk.com/api/v2/organizations (ZendeskAPI::Error::NetworkError)
rsl commented 2 years ago

make sure your account level has the capability to use organizations

ecoologic commented 1 year ago

Hi @rsl - did your second comment solved your problem? I did not experience this problem with proper permissions, I was able to create the organization as expected.

ecoologic commented 1 year ago

Please try the latest version of our gem and feel free to re-open this issue if your problem persists.

rsl commented 1 year ago

oh yeah. the second comment [from myself] was so others that hit this could see a solution. was purely permissions issue.