postman use csrf token

1, the request Tests

Adding the following code:

var csrf_token = postman.getResponseCookie("csrftoken").value
postman.clearGlobalVariable("csrftoken");
postman.setGlobalVariable("csrftoken", csrf_token);
pm.environment.get("variable_key");

Figure:

2, the request header is added:

X-CSRFToken: {{csrftoken}}

Figure:

Guess you like

Origin blog.csdn.net/qq_23903863/article/details/88797322