Update a User

You can use this API request to update or edit a previously created user that has already on your AnswerHub site.

/services/v2/user/[userId].json

You can use the following parameters in your update a user request:

Other options: wrap.

🚧

Permissions & Notes:

  • To change a user name through the API, you must have the Edit Users and Groups permission under Site Administration Roles in the Advanced Editor.

  • To update any user, you must have the Edit any profile permission under Moderation Roles in the Advanced Editor.

  • If the user account is your own, you must have the Edit own profile permission under Standard Roles in the Advanced Editor.

  • To edit any profile details, you must have the Edit any profile details (name, location, password, etc.) permission under Moderation Roles in the Advanced Editor.

    • If the user account is your own, you must have the Edit own profile details (name, location, password, etc.) under Standard Roles in the Advanced Editor.

    • Be very careful with this permission. Anyone with the Edit any profile details (name, location, password, etc.) can do exactly as the permissions states — edit anyone's password. Only give this permission to trusted people.

  • You can specify the data describing what user information you are editing or updating, both in the body of the request, or as a request parameter, with the same names as the fields in the body.

    • When you send data in the body of the request, the format should match the URL extension, or the value of the site's HTTP request header content-type.
    • If you specify data values for the same field, both on the request body and as a request or query parameters, the value of the parameters takes precedence over the value in the body.
  • Notice: The UserRequest data model includes a field for the user password; we consider using a secure connection to post this request to be a best practice. In this case, the request URL uses protocol prefix HTTPs, which indicates that a secured connection using a protocol such as SSL/TLS (based on a asymmetric-key cryptography) gets used to make the request.

  • We added this request in version 1.6.3.

Sample Requests

A PUT update a user request to https://apidocs.cloud.answerhub.com using a human-readable Username/Password (answerhub:test123) that updates a user (userId: 110) to have a real name of "Jon Smith" would look like this:

curl 
-u "answerhub:test123" 
-H "Accept: application/json" 
-H "Content-type: application/json" 
-X PUT 
-d '{"realName":"Jon Smith"}' "https://apidocs.cloud.answerhub.com/services/v2/user/110.json" -v

Example of additional queries to update the user profile.

curl 
-u "answerhub:answerhub" 
-H "Accept: application/json" 
-H "Content-type: application/json" 
-X PUT 
-d '{"username":"jons","realName":"Jon Smith", "about":"some data about Jon", "location":"NC"}' "https://apidocs.cloud.answerhub.com/services/v2/user/110.json" -v

Sample Response with a Real Name Query

Successful Response to Update User 110 to have a real name of Jon Smith.

  • HTTP Status code 200 - OK
{
    "id": "110",
    "creationDate": 1549031543000,
    "creationDateFormatted": "02/01/2019 02:32 PM",
    "modificationDate": 1549034012073,
    "username": "JonS",
    "realname": "Jon Smith",
    "type": "user",
    "plug": "jons",
    "gold": 0,
    "silver": 0,
    "bronze": 0,
    "reputation": 0,
    "moderator": false,
    "superuser": false,
    "avatar": "http://apidocs.cloud.answerhub.com/users/110/photo/view.html",
    "company": "",
    "website": "",
    "location": "",
    "postCount": 0,
    "followerCount": 0,
    "followCount": 0,
    "userFollowCount": 0
}

Sample Response with About and Location Queries

Successful Response to Update User 110 to have a description in the about section and to add their location.

  • HTTP Status code 200 - OK
{
    "id": "110",
    "creationDate": 1549031543000,
    "creationDateFormatted": "02/01/2019 02:32 PM",
    "modificationDate": 1549047629717,
    "username": "jons",
    "realname": "Jon Smith",
    "type": "user",
    "plug": "jons",
    "gold": 1,
    "silver": 0,
    "bronze": 0,
    "reputation": 0,
    "moderator": false,
    "superuser": false,
    "avatar": "http://apidocs.cloud.answerhub.com/users/110/photo/view.html",
    "company": "",
    "website": "",
    "location": "NC",
    "postCount": 0,
    "followerCount": 0,
    "followCount": 0,
    "userFollowCount": 0
}

Community User Interface Result

Jon S Profile with additional info

Language
Authentication
Basic
base64
:
Click Try It! to start a request and see the response here!