Official comment


Hi Hanhui,
Your welcome.
Btw I have published a blog on the BSS API that you may find helpful: http://shapeblue.com/citrix/working-with-the-citrix-cloudportal-business-manager-2-1-bss-api/
Regards.
I believe some of you guys have met or resolved the exception "No such user found" before. Just wish any of you could kindly help me out to review with this case:
1.We have a skey(root user), apikey and a CPBM server running, define the follow variables to generate parameterto get the channels list:
String urlString = "/channels?_="+getTime()+"&apikey=u-i2sv--W8ItJRikn1eWK77VSmlbfwHvML-wmGyoOtaX06JoHZD3tDKWFff6tCReQhub6JRB9F25EF3qUmjk7g";
String sKey = "GGo4Ps7pJsMsqN87bXt1YweGqRdme8LWVBW6J5ymz261VQsl5B4-Ee_HUcTRVVzw3UYvP0hLAH64rgqQleUn9g";
String BaseURL = "http://< CPBM server IP >/portal/api";
2.Lowercase the parameter string and encrypt and encode it :
public static String signRequest(String parameterString, String SecretKey) {
try {
parameterString = parameterString.toLowerCase();
System.out.println(parameterString);
Mac mac = Mac.getInstance("HmacSHA1");
SecretKeySpec keySpec = new SecretKeySpec(SecretKey.getBytes(), "HmacSHA1");
mac.init(keySpec);
mac.update(parameterString.getBytes());
byte[] encryptedBytes = mac.doFinal();
return URLEncoder.encode(Base64.encode(encryptedBytes), "UTF-8");
} catch (Exception ex) {
System.out.println(ex.getStackTrace());
}
3.Construct the final URL:
BaseURL+urlString+"&signature="+MACCoder.signRequest(urlString,sKey)
4.The final URL looks like:
http://< CPBM server IP >/portal/api/channels?_=1386234291515&apikey=u-i2sv--W8ItJRikn1eWK77VSmlbfwHvML-wmGyoOtaX06JoHZD3tDKWFff6tCReQhub6JRB9F25EF3qUmjk7g&signature=wpbgSlXGQjpO0MChfS5NB5T9kXA%3D
5.We always got the same output:
{"message":"No such user found","code":400","args":null}
Is there still any mistake?
The eDocs we have following: http://support.citrix.com/proddocs/topic/cpbm-21-map/cpbm-generatingsigntre-task.html . Also we attached the source code.
Hi Hanhui,
Your welcome.
Btw I have published a blog on the BSS API that you may find helpful: http://shapeblue.com/citrix/working-with-the-citrix-cloudportal-business-manager-2-1-bss-api/
Regards.
I'm on the road at the moment, but should be able to take a proper look later. But as a first, are the apiKey and sKey values of the CPBM root user from the CPBM database? Do not confuse these with ones you see in the CPBM UI in the root account.
hello Tariq ,
Thanks for the reminder, we did not realize there is a difference.
The input given is :
"
$api_key = "u-i2sv--W8ItJRikn1eWK77VSmlbfwHvML-wmGyoOtaX06JoHZD3tDKWFff6tCReQhub6JRB9F25EF3qUmjk7g";
$api_skey = "GGo4Ps7pJsMsqN87bXt1YweGqRdme8LWVBW6J5ymz261VQsl5B4-Ee_HUcTRVVzw3UYvP0hLAH64rgqQleUn9g";
"
And then we write some codes directly using this strings, we do not have a chance to check the database or UI yet.
Thanks if you could take a look.
Thanks Tariq for the quick response.
The keys were given by an administrator of CPBM and most likely it would not be wrong. By the way I have no idea of the difference of either taken from database or from CPBM UI, at all.
I assume the keys should be given "formally" from CPBM. Should it come from UI rather to query from table?
PS: the keys are:
The keys presented in the Portal UI are used in API calls to CloudPlatform/CloudStack.
To get the keys for the API calls to CloudPortal you will need get these from the cloud_portal.users DB table for the appropriate user in this case 'root' - these keys are not presented in the CPBM UI. The secret key value in the table is encrypted, so you will need to decrypt it first using AES before using it.
PS. If you dont have DB access but can access the CloudPlatform UI then compare the above keys with the ones for the admin user in CloudPlatform if they are the same then you have been given the wrong ones.
Thanks for explanation. Forgive me that I'm a fresh man to CPBM and have poor knowledge of it.
For now I am not able to access both UI and DB yet, but will check for that later when be able to.
Although the attached source code is not serious written but it seems should be able to get the correct URL, what do you think?
Many thanks again!
Hi Tariq,
Yes, it's been confirmed the keys were wrong, yes, their were from the UI which intended for CloudPlatform connection.
After we used the right keys the problem gone.
Thanks Tariq for the help last week.
Ask, Discuss, Answer