Forum Discussion

AnchalSingh's avatar
AnchalSingh
Qrew Member
4 years ago

Change user role for any user through APIs

Hi everyone,

I have a query related to changing user access to any app. I am trying revoke access for any user from the app through formula URL field. For that I am using API_ChangeUserRole, but prior to that I need to fetch user ID and user Role and for that I am using API_GetUserRole and API_GetUserInfo.

And I am putting below mentioned code in URL field.

var text getUserID =  URLRoot() & "db/" & "main" & "?a=API_GetUserInfo" &  "&email=" & [Email ID];
var text getUserRoleID = URLRoot() & "db/" & "XXXXXXXX" & "?a=API_GetUserRole" & "&userid="  
                                               & URLEncode($getUserID);
var text changeUserRole =  URLRoot() & "db/" & Dbid() & "?a=API_ChangeUserRole" & "&userid=" &
                                                    URLEncode($getUserID) & "&roleid=" & URLEncode($getUserRoleID) &
                                                   "&newRoleID=" & URLEncode(X);
var text url = $getUserID & "&rdr=" & URLEncode($getUserRoleID)& URLEncode("&rdr="
                                                     &  URLEncode($changeUserRole));
$url

But when  I am trying to invoke the same, I am getting this error.
<qdbapi>
<action>API_GetUserRole</action>
<errcode>21</errcode>
<errtext>Unknown user</errtext>
</qdbapi>


Would you please let me know what changes should I make in URL to get desirable result.
#Thanks in advance

ā€‹

------------------------------
Anchal Kumar Singh
------------------------------

1 Reply

  • AustinK's avatar
    AustinK
    Qrew Commander
    In your first line your db where you have "main" needs to be changed to the actual dbid of your app. Click on the home button and then take that dbid from the URL. That is your main app id. The GetUserRole call also needs the same main db I just mentioned added here, if you have something different.

    You might also try changing your first line to this. var user getUserID = instead of text, might not matter though.