Jump to content
Changes to the Jaspersoft community edition download ×

.NET Rest2 modify user role


elwin_1

Recommended Posts

Hi,

Jaspersoft server 6.1.

I'm stuck on the modify part of the user, I can login via Rest but not able to change the roles, error 404. If I try via rest client I get a nasty error (

<errorDescriptor>

<errorCode>
unexpected.error
</errorCode>
<message>
object references an unsaved transient instance - save the transient instance before flushing: com.jaspersoft.jasperserver.api.metadata.user.domain.impl.hibernate.RepoRole; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: com.jaspersoft.jasperserver.api.metadata.user.domain.impl.hibernate.RepoRole
</message>)

This is the .NET code:

 

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
 
namespace JasperUsersync
{
    class Program
    {
        static void Main(string[] args)
        {
            // Setup WebClient 
            WebClient httpclient = new WebClient();
          var server = "http://local:8080//reportservice";
            var login = server + "//rest//login";
 
            //Set the content type of the request
           httpclient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
  
 
            // Send PUT
 
              //Set the username and password
            NameValueCollection parametros = new NameValueCollection();
            parametros.Add("j_username", "superuser");
            parametros.Add("j_password", "pwd");
 
            //Request to login
            httpclient.UploadValues(login, "POST", parametros);
 
            //Get session cookie
            string session = httpclient.ResponseHeaders.Get("Set-Cookie");
 
            //Set session cookie to the next request
            httpclient.Headers.Add("Cookie", session);
           string userURL = ("http://local:8080//reportservice//rest_v2//permissions//organizations//myorg//users//Testadmin");
      
 
            string json = "{"enabled":true, "roles": [{"name":"ROLE_USER"}, {"name":"CSK_ROLE_PROJECT_MANAGEMENT"} ]}";
             
             httpclient.Headers[HttpRequestHeader.ContentType] = "application/json";
 
             string response = httpclient.UploadString(userURL, "PUT", json);
     
 
        }
  
 
}
 
What is the clue ???
 
kind regards,
 
Elwin
 
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...