0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SalesforceのSessionIdをPostmanで取得

Last updated at Posted at 2024-04-14

要件

PostmanでSalesforceのログインがさせる。セッションIDを取得する
またSalesforceのSOAPAPIを試す

Login

Step1 URLとヘッダー設定

image.png

※SOAPActionは空白できない。''は可
 URL:  https://login.salesforce.com/services/Soap/c/59.0

Step2 ID/password+Token とTokenの設定

Body部にRawデータでXMLを指定

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <n1:login xmlns:n1="urn:enterprise.soap.sforce.com">
      <n1:username>useridxxxxx</n1:username>
      <n1:password>password+Token</n1:password>
    </n1:login>
  </env:Body>
</env:Envelope>

送信したら、ServerURLとSessionIDを貰える

QUERY

URLは上と同じ、SessionIDは上のもの
POSTする

<?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:SessionHeader>
        <urn:sessionId>00D4W000000FDql!ARsAQNrUfETTQnROXFeBTbBf2tpwKv_8SvnA4uJjlob9MvUkSoOJt09mc1Y_er45qxJ24jeDsQ_hVjv.RRhY8L21W.EWW4gu</urn:sessionId>
     </urn:SessionHeader>
  </soapenv:Header>
  <soapenv:Body>
     <urn:query>
        <urn:queryString>SELECT id,AccountNumber,Name FROM Account </urn:queryString>
     </urn:query>
  </soapenv:Body>
</soapenv:Envelope>

Insert

複数Insertの場合、 urn:updateMrutrue
シングルの場合、False

<?xml version="1.0" encoding="utf-8"?>   
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns:urn="urn:enterprise.soap.sforce.com"
  xmlns:urn1="urn:sobject.enterprise.soap.sforce.com"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
     <urn:SessionHeader>
        <urn:sessionId>00D4W000000FDql!ARsAQNrUfETTQnROXFeBTbBf2tpwKv_8SvnA4uJjlob9MvUkSoOJt09mc1Y_er45qxJ24jeDsQ_hVjv.RRhY8L21W.EWW4gu</urn:sessionId>
     </urn:SessionHeader>
     <urn:MruHeader>
         <urn:updateMru>true</urn:updateMru>
     </urn:MruHeader>
  </soapenv:Header>
  <soapenv:Body>
    <urn:create>
        <urn:sObjects xsi:type="urn1:School__c">
           <Name>Good Shephard Public School</Name>
           <Fees__c>200</Fees__c>
           <School_Address__c>North Carolina</School_Address__c>
           <School_Phone__c>6790985555</School_Phone__c>	
        </urn:sObjects>
          <urn:sObjects xsi:type="urn1:School__c">
           <Name>Sacred Heart Convent School</Name>
           <Fees__c>200</Fees__c>
           <School_Address__c>India</School_Address__c>
           <School_Phone__c>6754328888</School_Phone__c>	
        </urn:sObjects>
          <urn:sObjects xsi:type="urn1:School__c">
           <Name>Nosegay Public School</Name>
           <Fees__c>500</Fees__c>
           <School_Address__c>Jaipur, India</School_Address__c>
           <School_Phone__c>8907654444</School_Phone__c>	
        </urn:sObjects>
    </urn:create>
  </soapenv:Body>
</soapenv:Envelope>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?