By d4rty


2016-04-27 07:23:58 8 Comments

I have been using postman to explore a REST interface. When using Postman's code generation feature, regardless of which programming language I select, Postman will always add a postman-token attribute in the header. Why is it there?

See for example PHP Curl:

<?php

$curl = curl_init();

curl_setopt_array($curl, array(CURLOPT_URL => "https://myURL.com,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
  "authorization: Basic abcdefghijklmnop",
  "cache-control: no-cache",
  "postman-token: wt53gwg-e9bb-645d-g53d-e42f8765aut0"
  ),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}

1 comments

@d4rty 2016-04-27 07:42:12

This is primarily used to bypass a bug in Chrome. If an XMLHttpRequest is pending and another request is sent with the same parameters then Chrome returns the same response for both of them. Sending a random token avoids this issue. This can also help you distinguish between request on the server side.

See docs/settings postman.

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] how can i check if RESTAPI is down using curl php

  • 2018-04-30 08:18:06
  • Senior PHP Developer
  • 132 View
  • 0 Score
  • 2 Answer
  • Tags:   php curl

5 Answered Questions

[SOLVED] cURL not working sometimes and gives empty result

  • 2015-06-05 12:09:15
  • Vignesh
  • 2981 View
  • 6 Score
  • 5 Answer
  • Tags:   php curl

1 Answered Questions

[SOLVED] How to implement cache system in php for json api

1 Answered Questions

cURL not showing the whole GET parameter with PHP

1 Answered Questions

[SOLVED] Microsoft outlook API give 404 error

1 Answered Questions

[SOLVED] php Curl posting to PHPBB

  • 2013-01-30 21:50:56
  • exussum
  • 2095 View
  • 4 Score
  • 1 Answer
  • Tags:   php curl

2 Answered Questions

simulate a link call using php code

  • 2014-10-12 05:31:13
  • Rodniko
  • 122 View
  • 0 Score
  • 2 Answer
  • Tags:   php html curl

1 Answered Questions

[SOLVED] Get data from asp.net page using curl

1 Answered Questions

1 Answered Questions

[SOLVED] extract url from xml response and redirect

  • 2010-11-24 17:54:22
  • Bobbyblue
  • 641 View
  • 2 Score
  • 1 Answer
  • Tags:   php

Sponsored Content