I am not getting the either incident list or count of incidents from REST message?

KM SN
Tera Expert

when I am trying to insert a incident record in source instance it should compare in target instance incident table with same caller id incidents and if the count is more than 5 allow the creation of incident else abort the action.

but I am not getting the count and list of incidents in the body when try to see them in the log.


I-2.pngI-3.png
I-1.png

I-3.png

2 ACCEPTED SOLUTIONS

Hayo Lubbers
Kilo Sage

Hi @KM SN ,

 

I think you're looking for the X-Total-Count, which is part of the Header, not the body...

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/integrate/inbound-rest/concept/c_...

 

Probably something like : var count = response.getHeader('X-Total-Count');

HayoLubbers_0-1722414900882.png

 

 

Hope this helps,

Hayo

View solution in original post

Hi @KM SN ,

 

It is  the total number of records in the full collection.

X-Total-Count 

 

----------------------------------------------------------------
Mark this as Helpful / Accept the Solution if this helps.

View solution in original post

6 REPLIES 6

Hayo Lubbers
Kilo Sage

Hi @KM SN ,

 

I think you're looking for the X-Total-Count, which is part of the Header, not the body...

https://docs.servicenow.com/bundle/washingtondc-api-reference/page/integrate/inbound-rest/concept/c_...

 

Probably something like : var count = response.getHeader('X-Total-Count');

HayoLubbers_0-1722414900882.png

 

 

Hope this helps,

Hayo

I am not getting the data and count its showing as 0 might be as i am not getting the data? what could be reason that i am not getting the data?

i-5.png

I-4.png

Hayo Lubbers
Kilo Sage

Hi @KM SN ,

 

That might be of an authentication error or incorrect endpoint or ...

Can you log some more data?

 

Statuscode (should be 200) : 

gs.info(response.getStatusCode())
 
Maybe the error code and message?
gs.info(response.getErrorCode())
gs.info(response.getErrorMessage())

 

If everything is fine, comment out your queryparameter and add e.g. sysparm_limit=10, to make sure it's not the query.

 

 

 

Hey @Hayo Lubbers 

Thanks for your time I am getting what I am looking for.

May i know what X-Total-Count is exactly.