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

Probably best if you start with the scripted REST API docs:

https://docs.servicenow.com/bundle/tokyo-application-development/page/integrate/custom-web-services/... 

You basicaly create an API with the methods you need, then you can use server-side scripting to query the DB and return any kind of response you need, based on the path params, query params or request body, included in the request.

 

Theres some examples in the docs too. hope that helps a bit.

Thanks, alot @Tom Sienkiewicz 

 

I have gone through to the provided docs; I got a doubt that do we have to use GET http method? Is it to get data from other source to snow or other sources can get data from SNOW?

Please confirm.

Thanks

Scripted REST API is inbound from an external system into ServiceNow. 

You can define e.g. a POST method which will allow you to use headers and request body to handle the long query. But ideally, such long query should be avoided so please look into the other suggestions as well (especially passign not a list of sys_ids but a filter or query params which will allow ServiceNow to filter out the required users.