auth0-cli icon indicating copy to clipboard operation
auth0-cli copied to clipboard

Organization update does not work

Open Yoshiji opened this issue 3 years ago • 0 comments

Description

The orgs update command does not work. The payload sent to the API includes the Organization's ID, which is not allowed: https://auth0.com/docs/api/management/v2/#!/Organizations/patch_organizations_by_id The Organization's ID must be present in the URL, not in the body of the request.

Reproduction

$ auth0 orgs update <id> -b "#BADA55"
=== optable-dev.us.auth0.com error
 ▸    400 Bad Request: Payload validation error: 'Additional properties not allowed: id'.

Environment

  • Version of this library used: latest main version (currently 7b0d17c)
  • Version of the platform or framework used, if applicable: N/A
  • Other relevant versions (language, server software, OS, browser): N/A
  • Other modules/plugins/libraries that might be involved: N/A

How to fix

Omitting the Organization's ID when building the request payload in updateOrganizationCmd fixes the issue. I can make a PR out of it, but I am unsure if this is how you would like to fix it.

diff --git a/internal/cli/organizations.go b/internal/cli/organizations.go
index 80f85dd..66479f9 100644
--- a/internal/cli/organizations.go
+++ b/internal/cli/organizations.go
@@ -323,7 +323,7 @@ auth0 orgs update <id> -d "My Organization" -m "KEY=value" -m "OTHER_KEY=other_v
                        // re-hydrated by the SDK, which we'll use below during
                        // display.
                        o := &management.Organization{
-                               ID:          current.ID,
+                               // ID:          current.ID,
                                DisplayName: &inputs.DisplayName,
                        }

Yoshiji avatar Jul 19 '22 20:07 Yoshiji