URL export is not working with JSON

Akshay03
Kilo Sage

Could someone please explain why the URL export functionality doesn't seem to work with JSON format using the provided examples?

 

Link 1 : https://<serviceNow-instance-name>/u_sn_sm_finance_request_list.do?XLSX&sysparm_query=company.u_deli...

 

Link 2 : https://<serviceNow-instance-name>/u_sn_sm_finance_request_list.do?JSON&sysparm_query=company.u_deli...

 

For instance:

Link 1: When accessing this link, which includes XLSX&sysparm_query=, a direct download of an .xlsx file is initiated. This behavior also applies to CSV and PDF formats.

 

Link 2: In contrast, when attempting to access this link, which includes JSON&sysparm_query=, the expected behavior of initiating a direct download doesn't occur. Instead, the download of a JSON file doesn't seem to work as intended. it will open u_sn_sm_finance_request table in list view.

 

To clarify, Link 1 successfully triggers a direct download of the file in various formats such as XLSX, CSV, and PDF. However, with Link 2, which is structured for JSON download, the anticipated direct download doesn't take place.

4 REPLIES 4

SwarnadeepNandy
Mega Sage

Hello @Akshay03,

 

The URL export functionality works with JSON format by using the ?JSONv2 parameter instead of ?JSON. The ?JSON parameter is used to display a list of records in JSON format, but not to export them as a file. The ?JSONv2 parameter is used to export data as a JSON file, similar to how the ?CSV or ?XLSX parameters work.

To use the URL export functionality with JSON format, you need to modify your link 2 as follows:

https://<serviceNow-instance-name>/u_sn_sm_finance_request_list.do?JSONv2&sysparm_query=company.u_deli…

This link should initiate a direct download of a JSON file containing the data from the u_sn_sm_finance_request table that matches the query.

 

Hope this helps.

 

Kind Regards,

Swarnadeep Nandy

 

Hello @SwarnadeepNandy ,

Thanks for reply.
I've tried solution provided by you. When i edited ?JSONv2 in link, direct download didn't trigger but it opened JSON view in browser. 
Check screenshot for reference.

Hello @SwarnadeepNandy 

I have same issue with XML type also.
when i add ?XML in url it just open XML view of page, it will not trigger download.

Is this functionality OOB? or we need to make changes in our instance?

Hello @Akshay03,

 

The behavior is the same for me as well. I think that's most probably how it is in ServiceNow.

But when I checked the JSON UI action, it was downloading the file. I'm not sure why it is so. I will let you know If I find something.

 

Kind Regards,

Swarnadeep Nandy