I wanna change the homepage of a Force.com Site using the Metadata API. Nothing fancy, so:
- I've prepared a new
updateMetadata
request, - set
fullName
to the API name of the site, - put
indexPage
to the Visualforce Page, - populate the other "required fields",
Then POST all that to the SOAP endpoint. But the response is a little bit confuzzling for me:
DUPLICATE_VALUE: A site with those parameters is already in use.
I guess it's true, the CustomSite exists, I want to update it. What am I missing here?
curl \
-X POST 'https://na1.salesforce.com/services/Soap/m/34.0' \
--header 'Content-Type: text/xml' \
--header 'SoapAction: ""' \
--data @request.xml
(request)
<?xml version="1.0" encoding="utf-8"?>
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header>
<urn:SessionHeader xmlns:urn="http://soap.sforce.com/2006/04/metadata">
<urn:sessionId>{session_id}</urn:sessionId>
</urn:SessionHeader>
</env:Header>
<env:Body>
<updateMetadata xmlns="http://soap.sforce.com/2006/04/metadata">
<metadata xsi:type="CustomSite">
<fullName>site_name</fullName>
<indexPage>MySiteHomePage</indexPage>
<clickjackProtectionLevel>SameOriginOnly</clickjackProtectionLevel>
<masterLabel>my site label</masterLabel>
<siteType>Visualforce</siteType>
<requireHttps>false</requireHttps>
</metadata>
</updateMetadata>
</env:Body>
</env:Envelope>
(response)
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/2006/04/metadata">
<soapenv:Body>
<updateMetadataResponse>
<result>
<errors>
<message>A site with those parameters is already in use.</message>
<statusCode>DUPLICATE_VALUE</statusCode>
</errors>
<fullName>site_name</fullName>
<success>false</success>
</result>
</updateMetadataResponse>
</soapenv:Body>
</soapenv:Envelope>