English 中文(简体)
改动用户角色的要求
原标题:strapi rest api request to change user role

在中央直辖区提出请求后,I m:

url: http://localhost:1337/api/users/3
payload: {
    "data": {
        "role": {
            "set": [{"id": 2}]
        }
    }
}

由于某种原因,我没有更新用户的作用,但我得到全面答复,但Id仍然扮演着以下角色:反应正在逐渐消失,为什么它没有更新用户作用,以及它如何适当发挥作用?

{
    "id": 3,
    "username": "czlenson",
    "email": "[email protected]",
    "provider": "local",
    "confirmed": true,
    "blocked": false,
    "createdAt": "2023-04-13T19:46:40.331Z",
    "updatedAt": "2023-04-13T20:15:24.804Z",
    "role": {
        "id": 1,
        "name": "Authenticated",
        "description": "Default role given to authenticated user.",
        "type": "authenticated",
        "createdAt": "2023-04-04T05:04:15.336Z",
        "updatedAt": "2023-04-13T20:11:24.318Z"
    }
}
问题回答

如果这一答复稍晚,我感到担忧,但你只是需要寄出像这样的有效载荷:

{
  "role": 2 #id of the role 
}

不要忘记改变允许改变这种作用(通过Strapi Admin)?

PUT的要求还将使用户重新发挥新作用。





相关问题
JQuery/MVC Search Issue

I have inherited a piece of work where the entry screen shows a summary of 20 calculated variables. E.g. Var A (250), Var B (79). Clicking on any of these links takes the user to a view with a ...

jQuery quicksearch plug-in tinkering with JSON

I ve implemented the quicksearch plugin by Rik Lomas and I love it for an application in a custom CMS I m building. I was wondering though, since I m going to have a bizillion items in the table if ...

JSON with classes?

Is there a standardized way to store classes in JSON, and then converting them back into classes again from a string? For example, I might have an array of objects of type Questions. I d like to ...

PHP json_decode question

i m trying to use json_decode to combine a few json objects and then re-encode it. my json looks like: { "core": { "segment": [ { "id": 7, "...

Converting JSON data to Java object

I want to be able to access properties from a JSON string within my Java action method. The string is available by simply saying myJsonString = object.getJson(). Below is an example of what the string ...

热门标签