- Revenera Community
- :
- FlexNet Operations
- :
- FlexNet Operations Forum
- :
- Re: Trying to use Rest API to Register the Activation ID from Postman
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hello,
I am trying to use Rest API to Register the Activation ID from Postman. The reply is 404
The entitlement with the activation id is deployed. See attachment .
url: https://<domain>-ns-uat.flexnetoperations.com/uai/2.0/devices/registrations
header: includes bearer token for the Json Web Token
Body:
{
"activationId": "ACT01-BMSClient",
"id": "KenPC",
"idType": "STRING",
"identityName": "UAIDeviceIdentity",
"publisherName": "bloom"
}
Thank you,
Ken
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi Ken,
I'll email you my Postman collection. I can't fully test without your JWT but I do get a valid response.
Thx,
Jim
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi Ken,
Something must be wrong with your request. I don't have your JWT but tried sending a similar request to your notification server and got back a valid Polling ID. When I check with the response with the Polling ID I got an invalid signature (as expected since I don't have your JWT).
You can always try the online Swagger page to directly test the UAI Rest APIs (UAT URL below):
https://{yoursite}-ns-uat.flexnetoperations.com/uai/documentation/swagger-ui.html
Thanks,
Jim
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi Ken,
I'll email you my Postman collection. I can't fully test without your JWT but I do get a valid response.
Thx,
Jim
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thanks so much Jim! I received a successful response on Swagger and also using C# code, which is the most important. It would be curious to see your Postman collection.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Can you please share C# sharp code as I am also facing the same issue.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Generic C# code.
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
client.BaseAddress = new Uri("https://youraddress-ns-uat.flexnetoperations.com/"); //This is for UAT environment
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", jsonWebToken); //Create a JSON Web Tokeb
ActivationRegistration activateRegistration = new ActivationRegistration(activationId, pcId, "STRING", identityName, publisherName);
HttpResponseMessage response = client.PostAsJsonAsync(
"uai/2.0/devices/registrations", activateRegistration).Result;
The ActivationRegistration class is generated on the https://json2csharp.com/ site. Use the JSON results example in Flexnet operations manual for Registration for the JSON.
I have renamed the classes generated.
The activation ID is setup by administration in the Flexnet portal, related to Entitlements.You choose the pcId. This will be used subsequently for updates.
The IdentityName and publisherName values can be found in the Flexnet Portal under Administer/Publishers and Administer/Indentity
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Thank for sharing a code.
Actually how will get a JSON Web token so that I can call further API's. Can you please help in that?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I think I generated the public and private keys with these steps, tried a few different ways a while back.
Step 1 To Generate Public and Private Keys
start cmd prompt
openssl genrsa -out UAIPrivate.pem 2048
cmd /k openssl rsa -inform PEM -outform PEM -in UAIPrivate.pem -pubout -out UAIPublic.pem
To create Public and private keys.
Step 2 Generate Json Web token
The Python program below was given to me from Revenera. For some reason it only works in the Jupiter Notebook, which is part of the Anaconda installation.
It did not work in the Spyder environment. I don't know how to do this from other languages. Please make sure that the public and private key file names
are correct in the program.
import jwt
import datetime
import sys
# Execute the python script by invoking the following # from the command line: python3 SignJWT.py SaaSDemoPrivate.pem
# Read the supplied private key file
#private_key = open('jwtRS256.key', 'r')
path = 'C:\\python\\revenera\\UAIPrivate.pem'
with open(path, 'r') as private_key:
private_key_string = private_key.read()
private_key.close()
# Setup the JWT's payload
payload = { 'exp': datetime.datetime.utcnow() + datetime.timedelta(days=3650) }
# Use PyJWT to encode a sign a JWT
token = jwt.encode( payload, private_key_string, algorithm='RS256')
# Present token to the user
print('Bearer ' + token.decode('ASCII'))