function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Michal Bajdek 13Michal Bajdek 13 

platform event via post request

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
 
 
SimonMillsSimonMills
Hi Michal - did you resolve this? I am finding the same problem when trying to post to a PE from outside SF.