Get the list of `organizations` from Chef API

Hey Guys, I’m trying to get the list of organizations from our chef server using API Documentation. The response I get back from the request is a html format of login page for chef-manage.

I’m using postman tool and Basic Auth (Authentication, Username and Password)

Is anyone experienced the same? Appreciate all your help.

Basic auth isn’t going to work, you need to use the X-Ops-Authorization scheme. Basic auth only works for /stats.

Thank you for answering, By any chance is there any documentation available for this ?

Only what is on the docs site … if you’re using the latest Chef Infra Server the docs are at https://docs.chef.io/server/api_chef_server/. Otherwise you’ll have to search for older docs in the archives, like https://docs-archive.chef.io/release/server_12-1/api_chef_server.html.

You could dig into the knife code to see how it is done there. https://github.com/chef/chef/blob/c9e8ca8a6f64c9663159caf03b91827638496b15/lib/chef/server_api.rb#L30 is the Chef::ServerAPI class, used by knife to talk to a Chef server.

There are a couple api clients out there. I’d recommend using one of them to make the api call. http://github.com/go-chef/chef|github.com/go-chef/chef is one I support and it can be used to list organizations.

But, would knife opc work for you? The initial overhead to set up the call is lower than using the api calls.