How to write multiline Elasticsearch scripts with Postman How to write multiline Elasticsearch scripts with Postman elasticsearch elasticsearch

How to write multiline Elasticsearch scripts with Postman


Triple-quotes in JSON are not technically valid -- see this thread for more info.

There are essentially three options:

  • Write a script which takes in a multiline 'JSON' and produces a \n-separated, valid JSON (what I often did prior to multiline backtick strings in JavaScript and still do in php:
function compactifyMultilineString( $input_string ){    return str_replace( array( "\r", "\n", "\t" ), " ", $input_string );}
  • Use postman's own pre-request scripts
  • Or, probably the most reasonable option, set up Kibana right next to your ElasticSearch server. Kibana is great for testing out queries and it also supports a postman-ready copy feature:

enter image description here