• Curt Schwaderer
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 2
    Replies
I have existing Python code that I want to integrate with the Salesforce REST APIs to create/update Salesforce objects. Are there any good examples out there that would be helpful?

Thanks!
I'm trying to use cURL to get data from an Apex REST endpoint.
I created an Apex class and tested it with the Salesforce Workbench: REST Explorer. That works fine.

I then used cURL to get the authentication information:
curl -v https://login.salesforce.com/services/oauth2/token (https://login.salesforce.com/services/oauth2/token" style="color:blue; text-decoration:underline) -d "grant_type=password" -d "client_id=<my_consumer_key>" -d "client_secret=<my_consumer_secret>" -d "username=<my_username>" -d "password=<my_password_and_security_token>" -H 'X-PrettyPrint:1'

When I run that, I get this information back which is correct:
{
"access_token":"<The Access Token/Session ID>",
"instance_url":"https://bitrouter-dev-ed.my.salesforce.com (https://bitrouter-dev-ed.my.salesforce.com" style="color:blue; text-decoration:underline)",
"id":"https://login.salesforce.com/id/00D4x000006sKbEEAU/0054x000003i2NjAAI (https://login.salesforce.com/id/00D4x000006sKbEEAU/0054x000003i2NjAAI" style="color:blue; text-decoration:underline)",
"token_type":"Bearer",
"issued_at":"1612817911089",
"signature":"BuvxwZJR/t7F2WBae2aVVev+TO+OjUN5oZW5WRf7x9Y="
}
* Connection #0 to host login.salesforce.com left intact

Finally, I run the cURL command to get the Case record information:
curl https://bitrouter-dev-ed.my.salesforce.com/services/apexrest/Cases/5004x0000042Iv1AAE (https://bitrouter-dev-ed.my.salesforce.com/services/apexrest/Cases/5004x0000042Iv1AAE" style="color:blue; text-decoration:underline) -H 'Authorization: Bearer <Access Token/Session ID>' -H "X-PrettyPrint:1"


I get the following response:

[ {
  "message" : "Session expired or invalid",
  "errorCode" : "INVALID_SESSION_ID"
} ]
curl: (6) Could not resolve host: Bearer
curl: (6) Could not resolve host: <Access Token/Session ID>'

Where the <Access Token/Session ID> is the access token string returned from the first cURL call that works.

Any idea what I'm doing wrong? Thanks!
Hi - I'm doing the Apex REST Callouts Trailhead tutorial and when I open the Developer Console then select Debug, the "Open Execute Autonomous Window" is greyed out. so instead I try "CTRL-E" which is supposed to open this - when I do, I get a pop-up window that says "You don't have permission to execute Apex". We have Salesforce Professional and Web API licensed. Shouldn't I be able to do this? How do I clear this permissions error? Thanks!
I'm trying to use cURL to get data from an Apex REST endpoint.
I created an Apex class and tested it with the Salesforce Workbench: REST Explorer. That works fine.

I then used cURL to get the authentication information:
curl -v https://login.salesforce.com/services/oauth2/token (https://login.salesforce.com/services/oauth2/token" style="color:blue; text-decoration:underline) -d "grant_type=password" -d "client_id=<my_consumer_key>" -d "client_secret=<my_consumer_secret>" -d "username=<my_username>" -d "password=<my_password_and_security_token>" -H 'X-PrettyPrint:1'

When I run that, I get this information back which is correct:
{
"access_token":"<The Access Token/Session ID>",
"instance_url":"https://bitrouter-dev-ed.my.salesforce.com (https://bitrouter-dev-ed.my.salesforce.com" style="color:blue; text-decoration:underline)",
"id":"https://login.salesforce.com/id/00D4x000006sKbEEAU/0054x000003i2NjAAI (https://login.salesforce.com/id/00D4x000006sKbEEAU/0054x000003i2NjAAI" style="color:blue; text-decoration:underline)",
"token_type":"Bearer",
"issued_at":"1612817911089",
"signature":"BuvxwZJR/t7F2WBae2aVVev+TO+OjUN5oZW5WRf7x9Y="
}
* Connection #0 to host login.salesforce.com left intact

Finally, I run the cURL command to get the Case record information:
curl https://bitrouter-dev-ed.my.salesforce.com/services/apexrest/Cases/5004x0000042Iv1AAE (https://bitrouter-dev-ed.my.salesforce.com/services/apexrest/Cases/5004x0000042Iv1AAE" style="color:blue; text-decoration:underline) -H 'Authorization: Bearer <Access Token/Session ID>' -H "X-PrettyPrint:1"


I get the following response:

[ {
  "message" : "Session expired or invalid",
  "errorCode" : "INVALID_SESSION_ID"
} ]
curl: (6) Could not resolve host: Bearer
curl: (6) Could not resolve host: <Access Token/Session ID>'

Where the <Access Token/Session ID> is the access token string returned from the first cURL call that works.

Any idea what I'm doing wrong? Thanks!
Hi - I'm doing the Apex REST Callouts Trailhead tutorial and when I open the Developer Console then select Debug, the "Open Execute Autonomous Window" is greyed out. so instead I try "CTRL-E" which is supposed to open this - when I do, I get a pop-up window that says "You don't have permission to execute Apex". We have Salesforce Professional and Web API licensed. Shouldn't I be able to do this? How do I clear this permissions error? Thanks!