- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 07:42 AM
We are working on ServiceNow integration with Clarizen application and have equirement to to call the system property (which contains APP Key) into Rest Message hearder.
I have added this code -
{"errorCode":"LoginFailure","message":"You are not authorized to access this service.","referenceId":"1gL04tE1dK87xaLU5gmZMJ"}
Can anybody help me with this? Do I need to create a system property as well?
Regards,
Kajol
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 07:48 AM
Hi @KajolM ,
Please check in the sys_properties table that a property with name "Clarizen" exists. If not then create one with the same name and add the API key in the value field. Now you should be able to call the system property in the Rest Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 11:21 AM
What I can articulate from what you have mentioned is that, the API is bringing in entire data in the response body ie let's say clarizen already has 1000 records in it's database and those 1000 records were imported into servicenow from API call for the first time. Now suppose 30 new records have been created in Clarizen and you are making an API call again, so this time you need 30 records as those 1000 records have already been imported but Clarizen is sending the data of 1030 records (1000 old + 30 new). And as per your present code it is creating duplicate records for the old records that were already imported.
We will check in the table if a record with Same user principal name and product exists, if yes then only update its last login time, if the user principal name and product doesn't exist then create a new record on servicenow with different field being populated
var r = new sn_ws.RESTMessageV2('Clarizen', 'Get User Subscription Data');
subscriptionGR.addQuery('product', obj.entities[i].product);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 07:48 AM
Hi @KajolM ,
Please check in the sys_properties table that a property with name "Clarizen" exists. If not then create one with the same name and add the API key in the value field. Now you should be able to call the system property in the Rest Message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 08:32 AM
Thanks @ShreyasK0030, it worked. I need another help.
I wrote this code to map the response into the software subscription table. The code is working, however, it is creating duplicates records every time I run the scheduled job.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-21-2024 11:21 AM
What I can articulate from what you have mentioned is that, the API is bringing in entire data in the response body ie let's say clarizen already has 1000 records in it's database and those 1000 records were imported into servicenow from API call for the first time. Now suppose 30 new records have been created in Clarizen and you are making an API call again, so this time you need 30 records as those 1000 records have already been imported but Clarizen is sending the data of 1030 records (1000 old + 30 new). And as per your present code it is creating duplicate records for the old records that were already imported.
We will check in the table if a record with Same user principal name and product exists, if yes then only update its last login time, if the user principal name and product doesn't exist then create a new record on servicenow with different field being populated
var r = new sn_ws.RESTMessageV2('Clarizen', 'Get User Subscription Data');
subscriptionGR.addQuery('product', obj.entities[i].product);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2024 03:20 AM
Hi @ShreyasK0030,
You're absolutely right, you got my requirement correctly.
I replaced subscriptionGR.addQuery('product', obj.entities[i].product); with subscriptionGR.addQuery('product', 'Clarizen'); as I am not getting the product value from the response and ran your code.
I got the 32 records(which is correct, I have 32 records in the Clarizen response).
Then, I deleted 1 record from the table(I am left with 31 records now), and ran the scheduled job again, this time I got 63 records (31 records from previous run + 32 records from new run), it means i am getting duplicate records.
Could you please help me out?
Regards,
Kajol