+ Start a Discussion
Joanna Knott 6Joanna Knott 6 

Portal ID requested when sending a SOAP API to sandbox

Here is the SOAP login envelope I am stuck on:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Header>
        <LoginScopeHeader xmlns="urn:partner.soap.sforce.com">
            <organizationId>00DJ0000003L9lt</organizationId>
            <portalId>[string?]</portalId>
    

Where do I find our Portal ID?
    
Deepak Kumar ShyoranDeepak Kumar Shyoran
To find the customer portal ID Go to Setup > Customer Portal > Setting then on Portal detial section you can find Portal Id.


User-added image
Joanna Knott 6Joanna Knott 6
We don't have Customer Portal set up. I am just trying to use a SOAP Call to call Salesforce sandbox from our website. 
Deepak Kumar ShyoranDeepak Kumar Shyoran
Well in that case you need to setup a customer portal first to get the portal Id.
Tim BatchelorTim Batchelor
It seems like with the advent of Communities, the portalId node is no longer needed to gain receive a session token via the SOAP API.

Create a file called authrequest.xml and set the organizationId, username and password.
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com">
  <soapenv:Header>
    <urn:LoginScopeHeader>
      <urn:organizationId>Replace with Setup->CompanyInfo->OrganizationId</urn:organizationId>
    </urn:LoginScopeHeader>
  </soapenv:Header>
  <soapenv:Body>
    <urn:login>
        <urn:username>username@example.com</urn:username>
        <urn:password>password</urn:password>
    </urn:login>
  </soapenv:Body>
</soapenv:Envelope>
curl -X POST -d @authrequest.xml https://login.salesforce.com/services/Soap/c/36.0 --header "Content-Type: text/xml; charset=UTF-8;" -H "SOAPAction: login"
Response from Salesforce includes <sessionId></sessionId>
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
    xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns="urn:enterprise.soap.sforce.com"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body>
        <loginResponse>
            <result>
             <metadataServerUrl>https://na49.salesforce.com/services/Soap/m/36.0/removed</metadataServerUrl>
                <passwordExpired>false</passwordExpired>
                <sandbox>false</sandbox>
                <serverUrl>https://na49.salesforce.com/services/Soap/c/36.0/removed</serverUrl>
                <sessionId><Extract the SessionId from the XML.</sessionId>
                <userId>removed</userId>
                <userInfo>
                    <accessibilityMode>false</accessibilityMode>
                    <currencySymbol>$</currencySymbol>
                    <orgAttachmentFileSizeLimit>5242880</orgAttachmentFileSizeLimit>
                    <orgDefaultCurrencyIsoCode>USD</orgDefaultCurrencyIsoCode>
                    <orgDisallowHtmlAttachments>false</orgDisallowHtmlAttachments>
                    <orgHasPersonAccounts>false</orgHasPersonAccounts>
                    <organizationId>removed</organizationId>
                    <organizationMultiCurrency>false</organizationMultiCurrency>
                    <organizationName>removed</organizationName>
                    <profileId>removed</profileId>
                    <roleId>00E5A000000LQtyUAG</roleId>
                    <sessionSecondsValid>7200</sessionSecondsValid>
                    <userDefaultCurrencyIsoCode xsi:nil="true"/>
                    <userEmail>removed</userEmail>
                    <userFullName>Archibald Charleson</userFullName>
                    <userId>removed</userId>
                    <userLanguage>en_US</userLanguage>
                    <userLocale>en_US</userLocale>
                    <userName>username@example.com</userName>
                    <userTimeZone>America/Los_Angeles</userTimeZone>
                    <userType>PowerCustomerSuccess</userType>
                    <userUiSkin>Theme3</userUiSkin>
                </userInfo>
            </result>
        </loginResponse>
    </soapenv:Body>
</soapenv:Envelope>