414 HTTP error (Request-URI Too Large) from ServiceNow API

Ksnow
Tera Contributor

Hi all,

 

One of our stakeholders reported that they're facing the issue that is "414 HTTP error (Request-URI Too Large)" while calling the API (GET method) from ServiceNow.

How to fix it from our side? Could anyone help/guide me on this?

It's really new for me in dealing with APIs and this kind of issues.

Appreciate your help!

Thanks,

Ksnow

 

1 ACCEPTED SOLUTION

Yeah that is going to be a problem then, if you use too many IDs in the query params. I think you have a couple options.

a) try to refine the query - perhaps base don an encoded query filter if possible, instead of providing individual user IDs

b) call the GET API with pagination - using offset, see below docs:

https://docs.servicenow.com/en-US/bundle/tokyo-application-development/page/integrate/inbound-rest/c... 

c) change the API from table API to a scripte dREST API. This will allow you to send any params as request header/body and not within URL. 

 

Perhaps theres other workarounds as well, these are the quickest ones I could think of. I know some people suggest changing method from GET to POST to use header/body params as well but con't remember if this owuld work with table API (I doubt it, and that is a dirty solution).

View solution in original post

7 REPLIES 7

Tom Sienkiewicz
Mega Sage

What kind of ServiceNow API is being used here? Scripted REST API? I would look into what is being passed in the URL within the GET as normally the URL should not be too long, perhaps the other systems tries to actually send a POST as a GET, putting everything in the URL instead of the header/body?

Thanks @Tom Sienkiewicz 

I have checked with the stakeholder and they are using standard ServiceNow API to get the user details by passing a list of all uses sys_id as parameter.

For example: URL: "{{ v_snowprod }}/api/now/table/sys_user?sysparm_query=sys_idIN{{ unique_uid_list }}", where unique_uid_list is the list of all user's uids (owners, backup owners, members of SG)

They're getting 414 HTTP error when calling sys_user table (cf above) because they are sending too much info inside the query (700+ sys_id : one by unique user).

 

Could you please help me how we can bypass this limitation then?

 

Thanks,
Ksnow

Yeah that is going to be a problem then, if you use too many IDs in the query params. I think you have a couple options.

a) try to refine the query - perhaps base don an encoded query filter if possible, instead of providing individual user IDs

b) call the GET API with pagination - using offset, see below docs:

https://docs.servicenow.com/en-US/bundle/tokyo-application-development/page/integrate/inbound-rest/c... 

c) change the API from table API to a scripte dREST API. This will allow you to send any params as request header/body and not within URL. 

 

Perhaps theres other workarounds as well, these are the quickest ones I could think of. I know some people suggest changing method from GET to POST to use header/body params as well but con't remember if this owuld work with table API (I doubt it, and that is a dirty solution).

Hello @Tom Sienkiewicz 

 

Thanks for providing options.

I am completely new to this, could you please help me with the steps to proceed further with the option C?

Please share sample code or something like that, I really appreciate your help.

 

Thanks,

Ksnow