Issue
When using the REST API RestMessage, executing multiple REST calls in a loop does not use the original session and creates several sessions that can in turn cause authentication errors.
- ]When viewing stats.do, you may see a list of many sessions being created after running scripted REST API.
- You receive 401 or 429 errors in subsequent REST calls when expecting to use the same session.
Cause
Session Cookie not formatted properly.
Resolution
Session RE-use is possible through the use of cookies. Cookies are sent in the SET-COOKIE Header and can be retrieved by using the getCookies(); method.
A cookie should be properly formatted in order to work. Example:
Example Real Cookie returned from response:
[JSESSIONID=BDE538E6F87C4FA2DFFA0DA9F6E4E14F;Secure; Path=/; HttpOnly, glide_user="";Secure; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly, glide_user_session="";Secure; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/; HttpOnly, glide_user_route=glide.9c5c58ba0c5169641af04031a4b26990;Secure; Expires=Wed, 02-Jan-2086 22:48:02 GMT; Path=/; HttpOnly, glide_session_store=41E2F0FDDBC38300E814FA56BF961953;Secure; Expires=Fri, 15-Dec-2017 20:03:55 GMT; Path=/; HttpOnly, BIGipServerpool_myinstancename=427827210.48704.0000; path=/]
Example of Cookie after formatted to send in subsequent calls:
JSESSIONID=BDE538E6F87C4FA2DFFA0DA9F6E4E14F;glide_user_route=glide.9c5c58ba0c5169641af04031a4b26990;glide_session_store=41E2F0FDDBC38300E814FA56BF961953;BIGipServerpool_myinstancename=427827210.48704.0000
The following code was used to properly format and store a cookie string and send in subsequent REST calls following an intial request: