If you use scripts or third party applications such as Postman, LiveAction, SolarWinds, or SevOne for Cisco SD-WAN Manager API requests, each request must include the token, unless the API is included in an allowed list. If an API request does
not include a token and is not included in the allowed list, Cisco SD-WAN Manager rejects the request and returns the response code 403 (forbidden) with the message, “SessionTokenFilter: Token provided via
HTTP Header does not match the token generated by the server.”
To request that certain API endpoints be included in an allowed list, open a case with the Cisco TAC or escalation support
team.
To include the token in a third party API request:
Method 1
In the first method, the session you create is stored in the cookies.txt file and the same session can be used for all subsequent
requests, using the jsessionid that the file contains. This is the recommended method.
-
To log in to Cisco SD-WAN Manager, use the following example command and modify the URL according to your IP address:
sampleuser$ TOKEN=$(curl "https://209.165.200.254/dataservice/client/token" -X GET -b cookies.txt -s -insecure)
To verify the login, see the cookies.txt file.
-
After logging in to Cisco SD-WAN Manager, obtain a token by making a request, where vManage_IP is the IP address of your Cisco SD-WAN Manager server. You can obtain a token in string format or in JSON format.
To obtain a token in string format, use the following URL:
https://vManage_IP/dataservice/client/token
To obtain a token in JSON format (beginning with Cisco IOS XE SD-WAN Release 16.12 and Cisco SD-WAN Release 19.2), use the
following URL:
https://vManage_IP/dataservice/client/token?json=true
The token that these calls return is valid for the rest of your current session. The following example shows requests for
obtaining a token:
Command for obtaining a token in string format:
sampleuser$ TOKEN=$(curl "https://vManage_IP/dataservice/client/token" -X GET -b cookies.txt -s -insecure)
Output in string format:
FC5B19BB3521EE20CFBDCD3CEDCC48F50CB1095C9654407936029E9C0EF99FEAE50440B60E49F7CD4A0BAB5307C2855F2E0C
Command for obtaining a token in JSON format:
TOKEN=$(curl "https://vManage_IP/dataservice/client/token?json=true" -X GET -b cookies.txt -s -insecure)
Output in JSON format:
sampleuser$ echo $TOKEN
{"token":"56CF324A8F67993B6FCCF57302068B0756DA8703BE712EEA18D4D9055B11312843F9D30B48A3902320FFAA8659AD01202A63"}
Note
|
JSON format is not supported for curl commands.
|
-
In the header of each subsequent API request in the current session, include the X-XSRF-TOKEN key, with a value that consists
of the token that you generated.
The following examples show a GET request and a POST request that include a generated token in the header:
Command:
sampleuser$ curl "https://vManage_IP/dataservice/server/info" -b cookies.txt -silent -insecure -H "X-XSRF-TOKEN: $TOKEN"
Output:
{"Achitecture":"amd64","Available processors":2}
Command
sampleuser$ curl "https://vManage_IP/dataservice/settings/configuration/emailNotificationSettings" -X POST -b cookies.txt -silent -insecure -H "X-XSRF-TOKEN: $TOKEN" -d '{"enabled":true,"from_address":"test@mydomain.com","protocol":"smtp","smtp_server":"a.com", "smtp_port":25,"reply_to_address":"test@test.com","notification_use_smtp_authentication":false}='
Output:
{"data":[{"enabled":true,"notification_use_email_setting_authentication":false,"notification_use_smtp_authentication":false}]}
- To prevent memory leaks, you must logout after each API call, including the token, starting from Cisco SD-WAN Release 19.2.1.
The following example shows how you can logout:
Command:
sampleuser$ curl "https://vManage_IP/logout" -b cookies.txt -insecure -H "X-XSRF-TOKEN:$TOKEN"
Output:
Replaced cookie JSESSIONID="DcOke5mqix_15qCpWA1blIJVAMnVg3lDMU4ABRgVinvalid" for domain 209.165.200.254, path /, expire 0
< set-cookie: JSESSIONID=DcOke5mqix_15qCpWA1blIJVAMnVg3lDMU4ABRgVinvalid
Note
|
To verify that you have logged out of the session, check the jsessionid and ensure that it ends with 'invalid'.
|
Method 2
In the second method, the session you create is not stored and you must create a new session for each request.
-
After logging in to Cisco SD-WAN Manager, obtain a token by making a request, where vManage_IP is the IP address of your Cisco SD-WAN Manager server. You can obtain a token in string format or in JSON format.
To obtain a token in string format, use the following URL:
https://vManage_IP/dataservice/client/token
To obtain a token in JSON format (beginning with Cisco IOS XE SD-WAN Release 16.12 and Cisco SD-WAN Release 19.2), use the
following URL:
https://vManage_IP/dataservice/client/token?json=true
The token that these calls return is valid for the rest of your current session. The following example shows requests for
obtaining a token:
Command for obtaining a token in string format:
sampleuser$ curl --user admin:admin https://vManage_IP/dataservice/client/token --insecure
Output in string format:
FC5B19BB3521EE20CFBDCD3CEDCC48F50CB1095C9654407936029E9C0EF99FEAE50440B60E49F7CD4A0BAB5307C2855F2E0C
Command for obtaining a token in JSON format:
sampleuser$ curl --user admin:admin https://vManage_IP/dataservice/client/token?json=true --insecure
{"token":"F1E047E444DB2CA4237B0246DFE133345584B788C6E8776F04749A371B73F3C0C683043F1CDBB5E01BBBDA7D6C35F58EA37A"}
Output in JSON format:
FC5B19BB3521EE20CFBDCD3CEDCC48F50CB1095C9654407936029E9C0EF99FEAE50440B60E49F7CD4A0BAB5307C2855F2E0C
-
In the header of each subsequent API request in the current session, include the X-XSRF-TOKEN key, with a value that consists
of the token that you generated.
The following examples show a GET request and a POST request that include a generated token in the header:
Command:
sampleuser$ curl "https://vManage_IP/dataservice/server/info" -H "Cookie:
JSESSIONID=pSwrx3AEWokiDO1TkFiOjgSehp-ITNdFn7Xj9PsL.c331d01e-91d7-41cc-ab90-b629c2ae6d97"
--insecure -H "X-XSRF-TOKEN=
FC5B19BB3521EE20CFBDCD3CEDCC48F50CB1095C9654407936029E9C0EF99FEAE50440B60E49F7CD4A0BAB5307C2855F2E0C"
Output:
{"Achitecture":"amd64","Available processors":2}
Command
sampleuser$
"https://vManage_IP/dataservice/settings/configuration/emailNotificationSettings" -H "Cookie:
JSESSIONID=pSwrx3AEWokiDO1TkFiOjgSehp-ITNdFn7Xj9PsL.c331d01e-91d7-41cc-ab90-b629c2ae6d97"
--insecure -H "X-XSRF-TOKEN=
FC5B19BB3521EE20CFBDCD3CEDCC48F50CB1095C9654407936029E9C0EF99FEAE50440B60E49F7CD4A0BAB5307C2855F2E0C"
-X POST --insecure -d
'{"enabled":true,"from_address":"test@mydomain.com","protocol":"smtp","smtp_server":"a.com",
"smtp_port":25,"reply_to_address":"test@test.com","notification_use_smtp_authentication":false}='
Output:
{"data":[{"enabled":true,"protocol":"smtp","smtp_server":"a.com","from_address":"test@mydomain.com",
"smtp_port":25,"notification_use_smtp_authentication":false,"reply_to_address":"test@test.com"}]}
- To prevent memory leaks, you must logout after each API call, including the token, starting from Cisco SD-WAN Release 19.2.1.
The following example shows how you can logout:
Command:
sampleuser$ curl "https://vManage_IP/logout" -b cookies.txt --insecure -H "X-XSRF-TOKEN:$TOKEN"
Output:
Replaced cookie JSESSIONID="DcOke5mqix_15qCpWA1blIJVAMnVg3lDMU4ABRgVinvalid" for domain 209.165.200.254, path /, expire 0
< set-cookie: JSESSIONID=DcOke5mqix_15qCpWA1blIJVAMnVg3lDMU4ABRgVinvalid
Note
|
To verify that you have logged out of the session, check the jsessionid and ensure that it ends with 'invalid'.
|