• Michal Bajdek 13
  • NEWBIE
  • 0 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hello, I am trying to create new Platform Event using REST call. I have found an trailhead with “Spotted Bear” application, and it works on my dev environment (I also have own domain and connected app). Then I use following endpoint: https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=cliend_id_from_connectedapp&redirect_uri=redirecturi

I get following response:
 
{
    "id": "https://login.salesforce.com/id/test/test",
    "asserted_user": true,
    "user_id": "test",
    "organization_id": "test",
    "username": "email@icloud.com",
    "nick_name": "email",
    "display_name": "Michal Surname",
    "email": "email@icloud.com",
    "email_verified": true,
    "first_name": "Michal",
    "last_name": "Surname",
    "timezone": "Europe/Dublin",
    "photos": {
        "picture": "https://myapp-dev-ed--c.eu11.content.force.com/profilephoto/id/F",
        "thumbnail": "https://myapp-dev-ed--c.eu11.content.force.com/profilephoto/id/T"
    },
    "addr_street": null,
    "addr_city": null,
    "addr_state": null,
    "addr_country": "PL",
    "addr_zip": null,
    "mobile_phone": null,
    "mobile_phone_verified": false,
    "is_lightning_login_user": false,
    "status": {
        "created_date": null,
        "body": null
    },
    "urls": {
        "enterprise": "https://myapp-dev-ed.my.salesforce.com/services/Soap/c/{version}/id",
        "metadata": "https://myapp-dev-ed.my.salesforce.com/services/Soap/m/{version}/id",
        "partner": "https://myapp-dev-ed.my.salesforce.com/services/Soap/u/{version}/id",
        "rest": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/",
        "sobjects": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/sobjects/",
        "search": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/search/",
        "query": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/query/",
        "recent": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/recent/",
        "tooling_soap": "https://myapp-dev-ed.my.salesforce.com/services/Soap/T/{version}/id",
        "tooling_rest": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/tooling/",
        "profile": "https://myapp-dev-ed.my.salesforce.com/0050Y000002PAnbQAG",
        "feeds": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feeds",
        "groups": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/groups",
        "users": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/users",
        "feed_items": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feed-items",
        "feed_elements": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feed-elements",
        "custom_domain": "https://myapp-dev-ed.my.salesforce.com"
    },
    "active": true,
    "user_type": "STANDARD",
    "language": "en_US",
    "locale": "en_IE_EURO",
    "utcOffset": 0,
    "last_modified_date": "2017-09-18T13:46:11.000+0000",
    "is_app_installed": true
}


 
As a response I get many fields, but I need only “id” and “rest” , but when I am trying to create new platform event via url: https://mydomain.my.salesforce.com/services/data/v40.0 /sobjects/Notification__e/
 
As a response I get only:
 
[
    {
        "message": "Session expired or invalid",
        "errorCode": "INVALID_SESSION_ID"
    }
]


 
I do not know what to do since there is no information about session_id: https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_publish_api.htm
 
 
Hello, I am trying to create new Platform Event using REST call. I have found an trailhead with “Spotted Bear” application, and it works on my dev environment (I also have own domain and connected app). Then I use following endpoint: https://test.salesforce.com/services/oauth2/authorize?response_type=code&client_id=cliend_id_from_connectedapp&redirect_uri=redirecturi

I get following response:
 
{
    "id": "https://login.salesforce.com/id/test/test",
    "asserted_user": true,
    "user_id": "test",
    "organization_id": "test",
    "username": "email@icloud.com",
    "nick_name": "email",
    "display_name": "Michal Surname",
    "email": "email@icloud.com",
    "email_verified": true,
    "first_name": "Michal",
    "last_name": "Surname",
    "timezone": "Europe/Dublin",
    "photos": {
        "picture": "https://myapp-dev-ed--c.eu11.content.force.com/profilephoto/id/F",
        "thumbnail": "https://myapp-dev-ed--c.eu11.content.force.com/profilephoto/id/T"
    },
    "addr_street": null,
    "addr_city": null,
    "addr_state": null,
    "addr_country": "PL",
    "addr_zip": null,
    "mobile_phone": null,
    "mobile_phone_verified": false,
    "is_lightning_login_user": false,
    "status": {
        "created_date": null,
        "body": null
    },
    "urls": {
        "enterprise": "https://myapp-dev-ed.my.salesforce.com/services/Soap/c/{version}/id",
        "metadata": "https://myapp-dev-ed.my.salesforce.com/services/Soap/m/{version}/id",
        "partner": "https://myapp-dev-ed.my.salesforce.com/services/Soap/u/{version}/id",
        "rest": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/",
        "sobjects": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/sobjects/",
        "search": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/search/",
        "query": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/query/",
        "recent": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/recent/",
        "tooling_soap": "https://myapp-dev-ed.my.salesforce.com/services/Soap/T/{version}/id",
        "tooling_rest": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/tooling/",
        "profile": "https://myapp-dev-ed.my.salesforce.com/0050Y000002PAnbQAG",
        "feeds": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feeds",
        "groups": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/groups",
        "users": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/users",
        "feed_items": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feed-items",
        "feed_elements": "https://myapp-dev-ed.my.salesforce.com/services/data/v{version}/chatter/feed-elements",
        "custom_domain": "https://myapp-dev-ed.my.salesforce.com"
    },
    "active": true,
    "user_type": "STANDARD",
    "language": "en_US",
    "locale": "en_IE_EURO",
    "utcOffset": 0,
    "last_modified_date": "2017-09-18T13:46:11.000+0000",
    "is_app_installed": true
}


 
As a response I get many fields, but I need only “id” and “rest” , but when I am trying to create new platform event via url: https://mydomain.my.salesforce.com/services/data/v40.0 /sobjects/Notification__e/
 
As a response I get only:
 
[
    {
        "message": "Session expired or invalid",
        "errorCode": "INVALID_SESSION_ID"
    }
]


 
I do not know what to do since there is no information about session_id: https://developer.salesforce.com/docs/atlas.en-us.platform_events.meta/platform_events/platform_events_publish_api.htm