Error 405 Only POST allowed throw when use SOAP api in Experience Cloud

experience-cloudsoap-api

I use SOAP api to get RecordType's information in my VF Page. When I use this VF Page in Experience Cloud with Partner user it will throw "Error 405 Only POST allowed".

Error Message as follow:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 405 Only POST allowed</title>
</head>
<body><h2>HTTP ERROR 405</h2>
<p>Problem accessing /services/Soap/u/40.0. Reason:
<pre>Only POST allowed</pre></p><hr /><br/>
<!-- Body events -->
<script type="text/javascript">function bodyOnLoad(){if(window.PreferenceBits){window.PreferenceBits.prototype.csrfToken="null";};}function bodyOnBeforeUnload(){}function bodyOnFocus(){}function bodyOnUnload(){}</script>
</body>
</html>

I try debug this error and I found it's in Salesforce's "connection.js" file.

enter image description here

"envelope" value as follow:

<se:Envelope xmlns:se=\"http://schemas.xmlsoap.org/soap/envelope/\">
<se:Header xmlns:sfns=\"urn:partner.soap.sforce.com\">
<sfns:SessionHeader>
<sessionId><--!My SessionId--></sessionId>
</sfns:SessionHeader>
<sfns:CallOptions>
<client><--!My Client--></client>
</sfns:CallOptions>
</se:Header>
<se:Body>
<describeLayout xmlns=\"urn:partner.soap.sforce.com\" xmlns:ns1=\"sobject.partner.soap.sforce.com\">
<sObjectType>Account</sObjectType>
<layoutName xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nill=\"true\"/>
<recordTypeIds>0125f000000tguIAAQ</recordTypeIds>
<recordTypeIds>0125f000000tgu8AAA</recordTypeIds>
</describeLayout>
</se:Body>
</se:Envelope>

Since Winter 19 I use SOAP api to get RecordType information, and as far as I know, this error never been meet before. I think maybe current Salesforce's update cause this issue.

Another found about this issue is SOAP api works fine when in Visualforce + Tabs type Experience.

Do you have any fix idea about this issue?

Best Answer

The reason is server url not correct in this case. Please add community prefixPath before server url.

Related Topic