curl command error: "Error on line 1: Content is not allowed in prolog."
search cancel

curl command error: "Error on line 1: Content is not allowed in prolog."

book

Article ID: 143059

calendar_today

Updated On:

Products

CA Infrastructure Management CA Performance Management - Usage and Administration DX NetOps

Issue/Introduction

Curl command fails when trying to do a PUT a discovery profile for devices.

Here is the command:

curl -v --user xxxx:xxxx  -X PUT  -H "Content-type: application/xml" -d "/tmp/xxxxxi.xml" --url http://xxxxxxx:8581/rest/discoveryprofiles/111111

Here is the error:

* About to connect() to xxxxxxx port 8581 (#0)

*   Trying xxxxxxxxxx... connected

* Connected to xxxxxxxx (xxxxxxxxx) port 8581 (#0)

* Server auth using Basic with user 'xxxxxx'

> PUT /rest/discoveryprofiles/111111 HTTP/1.1

> Authorization: Basic xxxxxxx=

> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2

> Host: xxxxxxxx:8581

> Accept: */*

> Content-type: application/xml

> Content-Length: 44

>

< HTTP/1.1 400 Bad Request

< Content-Type: text/xml

< Date: Fri, 10 Jan 2020 14:16:37 GMT

< Content-Length: 382

< Server: Jetty(8.1.17.v20150415)

<

<WebServiceException>

   <LocalizedMessage>The web service request failed because the XML provided in the request’s body did not conform to the defined schema (see the documentation at ‘discoveryprofiles/documentation’ for access to the schema definitions).The specific error was: "Error on line 1: Content is not allowed in prolog.".</LocalizedMessage>

* Connection #0 to host xxxxxxx left intact

* Closing connection #0

</WebServiceException>n

Environment

Release : 3.6

Component : IM Reporting / Admin / Configuration

Cause

The xml file might have a hidden Byte order Character and the encoding might be incorrect.

Resolution

Following are the steps :

cat /home/xxxxx/CAPC_discovery/xxxxxxx.xml

iconv -f CP1252 -t UTF-8 /tmp/xxxxxxx.xml

dos2unix

curl -v --user xxxxx:xxxxx -X PUT -H 'Content-type: application/xml' -d @/tmp/xxxxxxxxx.xml --url http:/xxxxxxxxx:8581/rest/discoveryprofiles/111111