function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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.
KIssasian momKIssasian mom
watch latest anime only on kissanime (https://kissanime.im)
gogoanime (https://gogoanimepro.net/)& gogoanime (http://gogoanimefy.com)
Anthony LincolnAnthony Lincoln
Thanks for sharing it. As we were facing the prolong content issue on mangaowl apk (https://freezapk.com/mangaowl-apk/). But after applying your script the issue got clear. Still it need to be improved but going to hire developer for it to fix the remaining issues.