Quick response on this would be helpful. I'm able to send request body from Workbench as source to my org as destination for creation of records. But what i need is how to perform the same operation using Postman tool or something else. Basically i have add authentication on my webservice class(means i have to allow my @httpPost method to access by only those for whom i give permission in my salesforce org based on username and password / Oauth methos.). Its for Webservice class @httpPost method.
-
Your question isn't very clear. What part are you getting stuck on? Have you read the documentation?– sfdcfox ♦Commented Jan 15, 2018 at 16:52
-
I have a Webservice class, which im testing through Workbench. i want to know how to add security for accessing my webservice class from third party. where i want something lie below in my webservice class for authentication purpose. HttpRequest req = new HttpRequest(); String username = 'theusername'; String password = 'thepasswork'; req.setHeader('Authorization', authorizationHeader);– Jayanth BCommented Jan 15, 2018 at 18:39
-
If you are calling salesforce service from workbench you will not need to set this , else you need to have either sessionId / Access token to call the service from third party where you can set the header as you have specified in the calling point . Also in this case you need to make sure that third party system is white listed in your company's firewall– freaker87Commented Jan 15, 2018 at 20:28
Add a comment
|
1 Answer
This is the way i found out to do, I tried this with postman tool. First enter the below URL with respective parameters and make a request for access token
Endpoint url = https://"yourOrgInstance".salesforce.com/services/oauth2/token
PARAMETERS
client_id = 3MVG99S6MzYiT5k8Wklml6FnGX5UVDSDSASADSAV.lWcKcPlMhaikiPoapcdX,
client_secret = 641362283729873987213897123,
username = [email protected],
password = *********,
grant_type = password.
AFTER OBTAINING THE ACCESS TOKEN
Endpoint url = https://"yourOrgInstance".salesforce.com/services/apexrest/StudentsDetails
HEADERS
Content-Type = application/json,
Authorization = Bearer 00D0l000000Cssm!AQEAQAhRNEsMvWDunFuM7XaPUs58vyI5wWYyLu06I5tUdCmoG3O5FsqRiVuL0JYM6091nUP0UlHGuzN60rBvkTMIiKyEQ6aK
or
Authorization = Bearer "AccessToken"
now add your request body and make a call.