Search code examples
djangosalesforcerestsalesforce-lightning

Retrieve data from Salesforce using Django


I am trying to integrate salesforce Rest API with Django, so for hours I have been trying to figure out the endpoint which it exposes, I have learned to create records but how do I access those records as the URL mentioned in docs is https://yourInstance.salesforce.com/services/data/v52.0/query/?q=SELECT+name+from+Account, what is "yourinstance" here, any help will be appreciated, thanks in advance

when i tried to access above URL in thunder client it gave me this error

Couldn't resolve the hostname to an IP address, Verify Url: https://trial65.salesforce.com/services/data/v52.0/query/?q=SELECT+name+from+Account

Solution

  • Assuming that you have created a Connected App, generated the client id/secret, to get the Bearer Token.

    In the response where you get your bearer token from Salesforce API refer this , it also provides you with instance URL as part of response.

    {"id":"https://login.salesforce.com/id/00Dx0000000BV7z/005x00000012Q9P",
    "issued_at":"1278448832702",
    "instance_url":"https://yourInstance.salesforce.com/",
    "signature":"0CmxinZir53Yex7nE0TD+zMpvIWYGb/bdJh6XfOH6EQ=",
    "access_token":"00Dx0000000BV7z!AR8AQAxo9UfVkh8AlV0Gomt9Czx9LjHnSSpwBMmbRcgKFmxOtvxjTrKW19ye6PE3Ds1eQz3z8jr3W7_VbWmEu4Q8TVGSTHxs",
    "token_type":"Bearer"}
    

    Goto Set Up > MyDomain There you'll find the My Instance URL for your salesforce org.

    Screen shot of MyDomain page for reference