Using database view in REST APIs

rajranbhare
Kilo Contributor

Hello,

I am using database view in servicenow REST API. I want to retrieve particular record from the view results.

Like for table api, we have the GET call (GET /api/now/table/<tablename>/<sys_id>). Can there be something like this for database view?

1 ACCEPTED SOLUTION

To Filter using OR conditions, you can add value for the sysparm_query = value=Service Desk^ORvalue=Software



The best way to get your query is to apply the filter on the table and Copy query by right clicking the filter and paste it on sysparm_query



find_real_file.png



The URL will be displayed in the API



find_real_file.png





Thanks


Please Hit like, Helpful or Correct depending on the impact of the response



View solution in original post

5 REPLIES 5

Alikutty A
Tera Sage

Hi Raj,



You can use the same get API, In place of table you should replace the table name of a database base view and you should be able to query it. You can try testing it for the OOB database view metric_instance from REST API explorer.



find_real_file.png



Click on Send and it will give a response data.



Thanks


Please Hit like, Helpful or Correct depending on the impact of the response


Hello Alikutty,


I was able to retrieve the results from database view using REST API. Let me rephrase my query. I want to apply filters to the results. How do I apply 'OR' operation in the url to filter the results?


To Filter using OR conditions, you can add value for the sysparm_query = value=Service Desk^ORvalue=Software



The best way to get your query is to apply the filter on the table and Copy query by right clicking the filter and paste it on sysparm_query



find_real_file.png



The URL will be displayed in the API



find_real_file.png





Thanks


Please Hit like, Helpful or Correct depending on the impact of the response



Hello Alikutty,


Thanks for your help.