- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 10:38 PM - edited 09-30-2024 10:40 PM
Hello everyone.
To getting started on this, can you share experiences or best practices for using the ServiceNow REST APIs? What common pitfalls should developers avoid?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:08 PM
Hi @VishaalRanS ,
Here are some best practices which you can follow while working with ServiceNow Rest API's:
- Always make sure your rest api user has required access to the table and data. I would also suggest to give only " Web Service access only " to restrict the user's access to api access only.
- Instead of Basic auth, try using the OAuth as its more secure than Basic Auth.
- Always log the API failures so that you can check the issues in details when required.
Please mark this solution as "Helpful" and "accepted solution" if this solution helped you in any way.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:29 PM
Hi @VishaalRanS
When utilizing ServiceNow Rest APIs, you should adhere to the following best practices:
- Always make sure your rest api user has required access to the table and data. I would also suggest to give only " Web Service access only " to restrict the user's access to api access only.
- Instead of Basic auth, try using the OAuth as its more secure than Basic Auth.
- Always log the API failures so that you can check the issues in details when required.
- In Rest API's, the best way to practice is Http method.
Please mark this solution as "Helpful" and "accepted solution" if this solution helped you in any way.
Regards,
Sai Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:57 PM
Hi @VishaalRanS ,
Please find below ref: Scripted REST API Best Practices - Quality Clouds Documentation
Enhancing API Security Practices in ServiceNow (reco.ai)
ServiceNow Blog | Crafting Good APIs in ServiceNow (rapdev.io)
Thanks & Regards,
Ramesh
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 12:12 AM
Hi @VishaalRanS
A few practices which should be followed while working with ServiceNow REST API's:
• Use OAuth or API tokens for authentication, and avoid hardcoding credentials in your code.
• Limit API calls with pagination and query parameters (sysparm_query, sysparm_fields) to fetch only necessary data.
• Handle rate limits and timeouts by implementing retry mechanisms and monitoring API usage.
• Test in development environments before pushing to production to avoid unintentional errors.
• Log and handle errors gracefully while ensuring that permissions are properly configured for API users.
You can also refer the following link to understand better.
I would appreciate if you can mark this response as correct or helpful if it helped you with your question.
Thanks,
Aryan Jain
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 04:30 AM
Here are some best practices and common pitfalls to avoid when using ServiceNow REST APIs:
Best Practices:
- Use RESTMessageV2: Utilize ServiceNow’s built-in RESTMessageV2 script object for simplicity and effi...1.
- Input Validation: Always validate and sanitize inputs to enhance security1.
- Error Handling: Implement robust error handling mechanisms to manage unexpected failures1.
- Asynchronous Processing: Leverage asynchronous processing to improve performance and avoid blocking ...1.
- Documentation: Maintain clear and comprehensive documentation for your APIs to ensure ease of use an...2.
Common Pitfalls:
- Ignoring Rate Limits: Be mindful of API rate limits to avoid throttling issues2.
- Poor Error Handling: Failing to handle errors properly can lead to unhandled exceptions and poor use...1.
- Lack of Security Measures: Not implementing proper authentication and authorization can expose your ...1.
I would appreciate if you can mark this response as correct or helpful if it helped you with your question.
Thanks,
Shalini.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:08 PM
Hi @VishaalRanS ,
Here are some best practices which you can follow while working with ServiceNow Rest API's:
- Always make sure your rest api user has required access to the table and data. I would also suggest to give only " Web Service access only " to restrict the user's access to api access only.
- Instead of Basic auth, try using the OAuth as its more secure than Basic Auth.
- Always log the API failures so that you can check the issues in details when required.
Please mark this solution as "Helpful" and "accepted solution" if this solution helped you in any way.
Thanks and Regards,
K. Sai Charan
Sr. ServiceNow Developer
Deloitte India
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:29 PM
Hi @VishaalRanS
When utilizing ServiceNow Rest APIs, you should adhere to the following best practices:
- Always make sure your rest api user has required access to the table and data. I would also suggest to give only " Web Service access only " to restrict the user's access to api access only.
- Instead of Basic auth, try using the OAuth as its more secure than Basic Auth.
- Always log the API failures so that you can check the issues in details when required.
- In Rest API's, the best way to practice is Http method.
Please mark this solution as "Helpful" and "accepted solution" if this solution helped you in any way.
Regards,
Sai Krishna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 11:57 PM
Hi @VishaalRanS ,
Please find below ref: Scripted REST API Best Practices - Quality Clouds Documentation
Enhancing API Security Practices in ServiceNow (reco.ai)
ServiceNow Blog | Crafting Good APIs in ServiceNow (rapdev.io)
Thanks & Regards,
Ramesh
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2024 12:12 AM
Hi @VishaalRanS
A few practices which should be followed while working with ServiceNow REST API's:
• Use OAuth or API tokens for authentication, and avoid hardcoding credentials in your code.
• Limit API calls with pagination and query parameters (sysparm_query, sysparm_fields) to fetch only necessary data.
• Handle rate limits and timeouts by implementing retry mechanisms and monitoring API usage.
• Test in development environments before pushing to production to avoid unintentional errors.
• Log and handle errors gracefully while ensuring that permissions are properly configured for API users.
You can also refer the following link to understand better.
I would appreciate if you can mark this response as correct or helpful if it helped you with your question.
Thanks,
Aryan Jain