Add roles to a user
1 min
code examples curl request put \\ \ url http //localhost 8080/profile permissions/users/{userid}/roles \\ \ header 'accept application/json' \\ \ header 'content type application/json' \\ \ data '{ "roleids" \[] }'var myheaders = new headers(); myheaders append("accept", "application/json"); myheaders append("content type", "application/json"); var raw = json stringify({ "roleids" \[] }); var requestoptions = { method 'put', headers myheaders, body raw, redirect 'follow' }; fetch("http //localhost 8080/profile permissions/users/{userid}/roles", requestoptions) then(response => response text()) then(result => console log(result)) catch(error => console log('error', error));require "uri" require "json" require "net/http" url = uri("http //localhost 8080/profile permissions/users/{userid}/roles") http = net http new(url host, url port); request = net http put new(url) request\["accept"] = "application/json" request\["content type"] = "application/json" request body = json dump({ "roleids" \[] }) response = http request(request) puts response read body import requests import json url = "http //localhost 8080/profile permissions/users/{userid}/roles" payload = json dumps({ "roleids" \[] }) headers = { 'accept' 'application/json', 'content type' 'application/json' } response = requests request("put", url, headers=headers, data=payload) print(response text) responses // roles added successfully { "userid" "", "roles" \[ { "roleid" "", "rolename" "operator", "assignedat" "", "assignedby" "", "expiresat" "" } ] }// invalid request parameters { "error" "not found", "message" "role not found", "details" "" }// missing or invalid authentication token { "error" "not found", "message" "role not found", "details" "" }// user or role not found { "error" "not found", "message" "role not found", "details" "" }// internal server error { "error" "not found", "message" "role not found", "details" "" }