Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
 Bo_PT
		
			Bo_PT
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		 marksouzacosta
		
			marksouzacosta
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi @Bo_PT,
I think you are missing userId and userDirectory fields. I think they are required according to this reference:
https://help.qlik.com/en-US/sense-developer/May2023/APIs/RepositoryServiceAPI/index.html?page=1911
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
 
					
				
		
 Øystein_Kolsrud
		
			Øystein_Kolsrud
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		I'm afraid I'm not familiar with that particular endpoint, but I have some ideas about what you could look into:
 
					
				
		
 Øystein_Kolsrud
		
			Øystein_Kolsrud
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Another thing: I find that a rather nice way to define those bodies are to use the anonymous object type in C#. You can turn those into a JObject and then pass it on as a body. Like this:
var body = JObject.FromObject(new
{
user = new { id = uid }
});
restClient.Post("/qrs/license/analyzeraccesstype/", body);
That way you can avoid all that convoluted string concatenation. I find it's very easy to miss a bracket or comma or something when I use that approach.
 Bo_PT
		
			Bo_PT
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		HI, Øystein_Kolsrud thanks for your reply and tips. I will try that.
Also I want to correct one typo error: The error I got is 400: bad request. (not 404).
 marksouzacosta
		
			marksouzacosta
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Hi @Bo_PT,
I think you are missing userId and userDirectory fields. I think they are required according to this reference:
https://help.qlik.com/en-US/sense-developer/May2023/APIs/RepositoryServiceAPI/index.html?page=1911
Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com
 Bo_PT
		
			Bo_PT
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		Thanks all for your reply. I haven't tried JObject thing yet but tried others. Here is the body part:
string body = "{";
body += "\"id\":\"" + uid + "\",";
body += "\"modifiedDate\":\"2024-08-14T04:56:07.000+00:00\",";
body += "\"user\":{";
body += "\"id\":\"" + uid + "\","; 
body += "\"userId\":\"" + userid + "\","; 
body += "\"userDirectory\":\"" + domainname + "\"}"; 
body += "}";
I still got 400 error.
 Bo_PT
		
			Bo_PT
		
		
		
		
		
		
		
		
	
			
		
		
			
					
		It works now. It turned out that there is a special character in uid which was somehow generated during copy & paste. It looks like letter 'a' which is why I missed it. Normally this type of character is only generated by foreign language input method, which I do not have on my laptop. Not sure how this happened.
Id, userid and userDirectory must be set to make it work. Other properties are optional. Here is the working code with minimum properties:
string body = "{";
body += "\"user\":{";
body += "\"id\":\"" + uid + "\","; 
body += "\"userId\":\"" + userid + "\",";
body += "\"userDirectory\":\"" + domainname + "\"}";
body += "}";
And JObject works too.
string uid = "<uid>"; 
string userid = "<userid>";
string udirectory = "<domainname>";
var body = JObject.FromObject(new
{
user = new { id = uid, userid = userid, userDirectory = udirectory }
});
Thanks again for everyone.
