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

[RC API] Fix the users endpoint to conform to standards when updating (PUT) a user #1312

Closed
ear-dev opened this issue Sep 28, 2022 · 4 comments · Fixed by #1317
Closed

[RC API] Fix the users endpoint to conform to standards when updating (PUT) a user #1312

ear-dev opened this issue Sep 28, 2022 · 4 comments · Fixed by #1317
Assignees

Comments

@ear-dev
Copy link

ear-dev commented Sep 28, 2022

The body of a POST request to the users endpoint looks like this:

{
  "username": "${agent_username}",
  "email": "${agent_email}",
  "password": "${agent_password}",
  "name": "${agent_name}",
  "roles": ["bot", "livechat-agent"],
  "active": true,
  "status": "online"
}

But the body of the PUT request on the users endpoint is nested like this:

{"data": 
    "user": {
        "username": "${agent_username}",
        "email": "${agent_email}",
        "password": "${agent_password}",
        "name": "${agent_name}",
        "roles": ["bot", "livechat-agent"],
        "active": true,
       "status": "online"
    }
}

This is a problem in our automation because we can only support a single template file for the body of an API request.

Can we modify the put request to handle the un-nested payload?

@AlexanderKanakis
Copy link
Collaborator

AlexanderKanakis commented Oct 4, 2022

@ear-dev are you sure that the current body has this form?

{
   "data": {
      "user": {}
   }
}

I sent a PUT request with this body successfully:

{
   "data": { }
}

@ear-dev
Copy link
Author

ear-dev commented Oct 4, 2022

{"data": { "user": {}}} worked for me, maybe it works for both?

But in any case, is it possible to factor such that we don't need the "data" block?

@AlexanderKanakis
Copy link
Collaborator

@ear-dev I have successfully modified the PUT method of users/:userId but we also have a POST method with users.update/:userId. Do we want to alter it too?

@ear-dev
Copy link
Author

ear-dev commented Oct 4, 2022

nope. that users.update endpoint is the legacy endpoint from upstream, and we do not want to use those. thanks.

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

Successfully merging a pull request may close this issue.

2 participants