+ Start a Discussion
mesmailmesmail 

Content is not allowed in prolog

In the following SF class code:

 

//2. make webservice call to create Rally Attachment
req.setEndpoint(RallyURL+':443/slm/webservice/1.26/attachmentcontent/create');
req.setMethod('POST');

req.setHeader('Authorization', authorizationHeader);
req.setHeader('Content-Type','text/xml');

String body;
body = '{"Content":"'+EncodingUtil.base64Encode(att.Body)+'"}';

req.setBody(body);

//send the request
res = http.send(req);
System.debug('***res1: ' + res.getBody());

 

 

I am getting the following error on response:

 

09:49:09.411 (1411487000)|USER_DEBUG|[79]|DEBUG|***res1: <?xml version="1.0" encoding="UTF-8"?>
<CreateResult rallyAPIMajor="1" rallyAPIMinor="26">
<Errors>
<OperationResultError>Cannot parse input stream as XML document: Error on line 1: Content is not allowed in prolog.</OperationResultError>
</Errors>
<Warnings />
</CreateResult>


Can you please assist me?

SuperfellSuperfell

Your content-type header says its xml, and given the error message, the server appears to be expecting xml, but your request body is not xml.

mesmailmesmail

Thanks Simon.  I altered the code little bit:

 

req.setEndpoint(RallyURL+':443/slm/webservice/1.26/attachmentcontent/create');
req.setMethod('POST');

req.setHeader('Authorization', authorizationHeader);
System.debug('***contenttype: ' + att.ContentType);
req.setHeader('Content-Type', att.ContentType+'; charset=UTF-8');

String body;
body = '{"Content":"'+EncodingUtil.base64Encode(att.Body)+'"}';

req.setBody(body);

//send the request
res = http.send(req);
System.debug('***res1: ' + res.getBody());

 

I am still getting the same error.

SuperfellSuperfell

You are still not sending xml, i susgest yo go find some example payloads for the service you're trying to call.

Rajesh kumar 570Rajesh kumar 570
This type of error comes when you put un-relevant content on visualforce page. Like i had put controller code on visualforcepage and got this error.