Logstash Create pipeline API: [pipeline] failed to parse object / json_parse_exception

Hello World!

I'm trying to follow this:

to duplicate an existing Logstash pipeline, however I'm running into following error:

% export PIPELINE=$(curl --silent --request GET --insecure "https://elastic:$es_password@localhost:9200/_logstash/pipeline/$pipeline_id")
% echo $PIPELINE | curl --silent --request PUT --insecure "https://elastic:$es_password@localhost:9200/_logstash/pipeline/copy-$pipeline_id?pretty" --header "Content-Type: application/json" --data-binary @-
{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[1:276] [pipeline] failed to parse object"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[1:276] [pipeline] failed to parse object",
    "caused_by" : {
      "type" : "json_parse_exception",
      "reason" : "Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 285]"
    }
  },
  "status" : 400
}
%

Please advise

Looks like you have a newline character in the data you are trying to parse as JSON, that needs to be quoted.