0

I am creating an application in angularjs. and I want to import contact of salesforce account in my application.

I have already got response of access_token and I am passing given below url.

url:'https://login.salesforce.com/services/oauth2/userinfo';

It returns me json which has given below response

{
    "id":"https://login.salesforce.com/id/00D50000000IZ3ZEAW/00550000001fg5OAAQ",
    "asserted_user":true,
    "user_id":"00550000001fg5OAAQ",
    "organization_id":"00D50000000IZ3ZEAW",
    "username":"user@example.com",
    "nick_name":"user1.2950476911907334E12",
    "display_name":"Sample User",
    "email":"user@example.com",
    "status":{
        "created_date":"2010-11-08T20:55:33.000+0000",
        "body":"Working on OAuth 2.0 article"
    },
    "photos":{
        "picture":"https://c.na1.content.force.com/profilephoto/005/F",
        "thumbnail":"https://c.na1.content.force.com/profilephoto/005/T"
    },
    "urls":{
        "enterprise":"https://na1.salesforce.com/services/Soap/c/{version}/00D50000000IZ3Z",
        "metadata":"https://na1.salesforce.com/services/Soap/m/{version}/00D50000000IZ3Z",
        "partner":"https://na1.salesforce.com/services/Soap/u/{version}/00D50000000IZ3Z",
        "rest":"https://na1.salesforce.com/services/data/v{version}/",
        "sobjects":"https://na1.salesforce.com/services/data/v{version}/sobjects/",
        "search":"https://na1.salesforce.com/services/data/v{version}/search/",
        "query":"https://na1.salesforce.com/services/data/v{version}/query/",
        "recent":"https://na1.salesforce.com/services/data/v{version}/recent/",
        "profile":"https://na1.salesforce.com/00550000001fg5OAAQ"
    },
    "active":true,
    "user_type":"STANDARD",
    "language":"en_US",
    "locale":"en_US",
    "utcOffset":-28800000,
    "last_modified_date":"2011-01-14T23:28:01.000+0000"
}

if I pass this url

url:'https://login.salesforce.com/services/data/v20.0/query/?q=SELECT+name,email,phone+from+Contact'
  • I am passing v20.0 manually, so what is use of it ? Can I pass it dynamically ?

it returns below response.

{
    "sobjects": "/services/data/v20.0/sobjects",
    "licensing": "/services/data/v20.0/licensing",
    "identity": "https://login.salesforce.com/id/22dfdfdf/ddds223",
    "connect": "/services/data/v20.0/connect",
    "search": "/services/data/v20.0/search",
    "query": "/services/data/v20.0/query",
    "tooling": "/services/data/v20.0/tooling",
    "chatter": "/services/data/v20.0/chatter",
    "recent": "/services/data/v20.0/recent"
}

I don't know what to do next and how to get contacts of salesforce account ? I have gone through doc but, could not have applied it.

Thanks ! :)

Updated

When I am passing this url

https://ap1.salesforce.com/services/data/v20.0/query/?q=SELECT+name,email,phone+from+Contact

It gives me below response

{
    "totalSize": 20,
    "done": true,
    "records": [
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2SAAT"
            },
            "Name": "Rose Gonzalez",
            "Email": "rose@edge.com",
            "Phone": "(512) 757-6000"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2TAAT"
            },
            "Name": "Sean Forbes",
            "Email": "sean@edge.com",
            "Phone": "(512) 757-6000"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2UAAT"
            },
            "Name": "Jack Rogers",
            "Email": "jrogers@burlington.com",
            "Phone": "(336) 222-7000"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2VAAT"
            },
            "Name": "Pat Stumuller",
            "Email": "pat@pyramid.net",
            "Phone": "(014) 427-4427"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2WAAT"
            },
            "Name": "Andy Young",
            "Email": "a_young@dickenson.com",
            "Phone": "(785) 241-6200"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2XAAT"
            },
            "Name": "Tim Barr",
            "Email": "barr_tim@grandhotels.com",
            "Phone": "(312) 596-1000"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2YAAT"
            },
            "Name": "John Bond",
            "Email": "bond_john@grandhotels.com",
            "Phone": "(312) 596-1000"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2ZAAT"
            },
            "Name": "Stella Pavlova",
            "Email": "spavlova@uog.com",
            "Phone": "(212) 842-5500"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2aAAD"
            },
            "Name": "Lauren Boyle",
            "Email": "lboyle@uog.com",
            "Phone": "(212) 842-5500"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2bAAD"
            },
            "Name": "Babara Levy",
            "Email": "b.levy@expressl&t.net",
            "Phone": "(503) 421-7800"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2cAAD"
            },
            "Name": "Josh Davis",
            "Email": "j.davis@expressl&t.net",
            "Phone": "(503) 421-7800"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2dAAD"
            },
            "Name": "Jane Grey",
            "Email": "jane_gray@uoa.edu",
            "Phone": "(520) 773-9050"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2eAAD"
            },
            "Name": "Arthur Song",
            "Email": "asong@uog.com",
            "Phone": "(212) 842-5500"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2fAAD"
            },
            "Name": "Ashley James",
            "Email": "ajames@uog.com",
            "Phone": "+44 191 4956203"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2gAAD"
            },
            "Name": "Tom Ripley",
            "Email": "tripley@uog.com",
            "Phone": "(650) 450-8810"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2hAAD"
            },
            "Name": "Liz D'Cruz",
            "Email": "ldcruz@uog.com",
            "Phone": "(650) 450-8810"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2iAAD"
            },
            "Name": "Edna Frank",
            "Email": "efrank@genepoint.com",
            "Phone": "(650) 867-3450"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2jAAD"
            },
            "Name": "Avi Green",
            "Email": "agreen@uog.com",
            "Phone": "(212) 842-5500"
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2kAAD"
            },
            "Name": "Siddartha Nedaerk",
            "Email": null,
            "Phone": null
        },
        {
            "attributes": {
                "type": "Contact",
                "url": "/services/data/v20.0/sobjects/Contact/0039000000RQz2lAAD"
            },
            "Name": "Jake Llorrac",
            "Email": null,
            "Phone": null
        }
    ]
}

but, it looks like it gives contact of any dummy account. which url do i need to pass ?

Do I need to pass id or instance_url to get Contacts ?

access_token: "ewew"
id: "https://login.salesforce.com/id/dsdsd"
id_token: dfd"
instance_url: "https://ap1.salesforce.com"
issued_at: "sdsd"
refresh_token: "dfdf"
scope: "id full api visualforce openid web refresh_token chatter_api"
signature: "sds"
token_type: "Bearer"
6

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.