Issue with Inaccurate internal_type Values in API Response for Empty Column Types

BineshJ
Giga Contributor

I am making an API call to retrieve details of a specific table & its columns.

 

API Request

 

 

https://subdomaim.service-now.com/api/now/v2/table/sys_dictionary?sysparm_query=name=sys_flow_listener&sysparm_fields=element,internal_type,primary,max_length,unique

 

 

Response

 

 

{
    "result": [
        {
            "unique": "false",
            "internal_type": {
                "link": "https://subdomain.service-now.com/api/now/v2/table/sys_glide_object?name=condition",
                "value": "condition"
            },
            "element": "listening_to",
            "primary": "false",
            "max_length": "2000"
        },
        ...
     ]
}

 

 

 

I noticed that for certain columns, the internal_type in the response is not appropriate. The link in the internal_type for some columns redirects to an irrelevant page.

Screenshot 2024-06-24 at 12.58.09 PM.png

I found that this issue occurs when the column type for those columns is empty.

 

Wouldn't it make more sense to return null or an empty string instead if the column type is empty?

 

Thank you.

 

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@BineshJ 

At first place why would you require an API to see the dictionary details? what's your business requirement?

I believe it's because the Type column is empty, did you try with some other fields?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

BineshJ
Giga Contributor

@Ankur Bawiskar 

 

My Requirement:

To process data from a user-specified table, I need to retrieve the table's column names and their respective data types. To obtain this information, I make an API call to the dictionary table.

 

I have also tried using other fields, and I noticed that the link in the 'internal_type' for those columns redirects me to a page displaying the response as(I believe this response is what I am expecting):

<response>
<result>
<use_original_value>true</use_original_value>
<visible>true</visible>
<sys_mod_count>7</sys_mod_count>
<label>Date/Time</label>
<scalar_type>datetime</scalar_type>
<sys_updated_on>2017-11-03 21:36:22</sys_updated_on>
<sys_class_name>sys_glide_object</sys_class_name>
<sys_id>***</sys_id>
<sys_package>
<link>https://subdomain.service-now.com/api/now/v2/table/sys_package/***</link>
<value>***</value>
</sys_package>
<sys_update_name>sys_glide_object_a54edbb1c0a80006014da86b91525bf3</sys_update_name>
<sys_updated_by>admin</sys_updated_by>
<sys_created_on>2004-05-19 00:00:00</sys_created_on>
<name>glide_date_time</name>
<sys_name>Date/Time</sys_name>
<attributes>edge_encryption_enabled=true</attributes>
<sys_scope>
<link>https://subdomain.service-now.com/api/now/v2/table/sys_scope/global</link>
<value>global</value>
</sys_scope>
<class_name>GlideDateTime</class_name>
<scalar_length/>
<sys_created_by>pat</sys_created_by>
<sys_policy/>
</result>
</response>

 

Regards,

Binesh.

 

Hi @BineshJ 

 

You can probably try to create a Scripted Rest API and see if that helps. Refer below posts :

https://www.servicenow.com/community/developer-forum/how-can-i-get-names-of-all-the-fields-of-table/...

https://www.servicenow.com/community/developer-forum/rest-api-to-fetch-all-table-s-columns-for-a-giv...

 

Thanks and Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.