I am new to salesforce and I followed instructions as per salesforce trailhead,    Access token got generated but, when I hit the url error occurs as,  "message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]curl: (6) Could not resolve host: Bearer.  But data is fetched successfully when I  try getting data through workbench.
123258
@RestResource(urlMapping='/Merchandise/*') global with sharing class MerchandiseManager {      @HttpGet     global static Merchandise__c getMerchandiseById() {         RestRequest req = RestContext.request;                 String merchId = req.requestURI.substring(                                   req.requestURI.lastIndexOf('/')+1);         Merchandise__c result =                         [SELECT Name,Description__c,Price__c,Total_Inventory__c                         FROM Merchandise__c                          WHERE Id = :merchId];         return result;     }      @HttpPost     global static String createMerchandise(String name,         String description, Decimal price, Double inventory) {         Merchandise__c m = new Merchandise__c(             Name=name,             Description__c=description,             Price__c=price,             Total_Inventory__c=inventory);         insert m;         return m.Id;     } }   i am trying to execute these from postman,    but throwing below error,how i can authenticate,please help urgent requirement.     {       "message": "Session expired or invalid",       "errorCode": "INVALID_SESSION_ID"   }
31428
I have a requirement to make a call to the  from a Lightning component. The issue I am facing is that there is currently no native support for acquiring a valid API session ID from an @AuraEnabled method in a Lightning component Apex controller.  The Lightning developer  states that a named credential can be used in order to bypass this security restriction. However, when I set up a named credential and then pass that named credential reference as the endpoint for the Metadata Service API, I am receiving the following error:     "FATAL_ERROR System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: This session is   not valid for use with the API faultcode=sf:INVALID_SESSION_ID   faultactor=".   I have found a potential  using Visualforce. However, the thread presenting this work around does not reference the "Named Credentials" feature as an option.  This  also presents the same issue where the documented named credential stops have been followed and the same error is received, but no solution has yet been offered.   I am not able to understand why the named credential feature is not bypassing the session id security measure for Lightning components.  Any input would be greatly appreciated.
46769
I'm trying to connect to a sandbox using the sfdx cli and the JWT flow through force:auth:jwt:grant. According to , we can use the same connected app information from Production to connect to our Scratch Org.  Is it something that should work for sandbox too ? I'm getting a "Failed: Not approved" error.  Connected app in sandbox comes from the refresh but has a different consumer key. The Permission set is set correctly on my user.  Is there a way to connect to a recently refreshed sandbox using the JWT flow (without manually changing something like the consumer key) ?
30628
Say I want to retrieve my API endpoint from a Visualforce Page or a Force.com Site, I can try:  Url.getSalesforceBaseUrl().toExternalForm();   But the return value is all over the place. It could be any of the following:   http://pod.salesforce.com (from a batch apex class) https://c.na1.visual.force.com (a local Visualforce Page) https://mysite.secure.force.com (from a Force.com Site) https://ns.pod.visual.force.com (some page in a managed package)   This wreaks havoc on the Remote Site Settings, and gets worse with Sites and Communities.  So how do I get just "https://na1.salesforce.com"?
28359
I'm trying to build an Android test application integrated to the SalesForce platform. I have downloaded the SDK from , and imported it to my workspace. Everything works fine except my test app, even the  they have provided along with the SDK work without problem. As a first step, what I tried was to clone the basic features (just login as of now) from the RestExplorer app. The following are my important files.  public class Home extends Activity {  private PasscodeManager passcodeManager; private RestClient client; private TokenRevocationReceiver tokenRevocationReceiver;  RestClient getClient() {     return client; }  @Override protected void onCreate(Bundle savedInstanceState) {     super.onCreate(savedInstanceState);      passcodeManager = SalesforceSDKManager.getInstance().getPasscodeManager();     tokenRevocationReceiver = new TokenRevocationReceiver(this);     setContentView(R.layout.activity_home);  }  @Override  public void onResume() {     super.onResume();     registerReceiver(tokenRevocationReceiver, new IntentFilter(ClientManager.ACCESS_TOKEN_REVOKE_INTENT));           if (passcodeManager.onResume(this)) {   // Bring up passcode screen if needed         String accountType = SalesforceSDKManager.getInstance().getAccountType();   // Login options         new ClientManager(this, accountType, SalesforceSDKManager.getInstance().getLoginOptions(), SalesforceSDKManager.getInstance().shouldLogoutWhenTokenRevoked()).getRestClient(this, new RestClientCallback() {    // Get a rest client             @Override             public void authenticatedRestClient(RestClient client) {                 if (client == null) {                     SalesforceSDKManager.getInstance().logout(Home.this);                     return;                 }                 Home.this.client = client;                           }         });     } }  @Override protected void onPause() {     passcodeManager.onPause(this);     unregisterReceiver(tokenRevocationReceiver);     super.onPause(); } }   I have added the permissions as required  &lt;permission android:name="com.salesforce.samples.restexplorer.C2D_MESSAGE"     android:protectionLevel="signature" /&gt;  &lt;uses-permission android:name="com.salesforce.samples.restexplorer.C2D_MESSAGE" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS"/&gt; &lt;uses-permission android:name="android.permission.MANAGE_ACCOUNTS"/&gt; &lt;uses-permission android:name="android.permission.ACCOUNT_MANAGER"/&gt;   And extended the application object to give a call to init();  public class MyApp extends Application { @Override public void onCreate() {     super.onCreate();     SalesforceSDKManager.initNative(getApplicationContext(), new KeyImpl(), Home.class); } }   Now, I'm getting the error in my Android debug log. The log as I see is attached below. It keep the activity restarting till I forcefully kill the application.  11-08 15:56:23.883: I/ClientManager:getRestClient(9334): No account of type com.salesforce.androisdk found 11-08 15:56:23.898: W/AccMgrCallback:run(9334): android.accounts.AuthenticatorException: bind failure 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at android.accounts.AccountManager.convertErrorToException(AccountManager.java:1726) 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at android.accounts.AccountManager.access$400(AccountManager.java:144) 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at android.accounts.AccountManager$AmsTask$Response.onError(AccountManager.java:1572) 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at android.accounts.IAccountManagerResponse$Stub.onTransact(IAccountManagerResponse.java:69) 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at android.os.Binder.execTransact(Binder.java:388) 11-08 15:56:23.898: W/AccMgrCallback:run(9334):     at dalvik.system.NativeStart.run(Native Method)   Do anyone have any idea about this isse? It is such a basic app, I was not expecting anything unusual. Did I do anything wrong in my app?
74200
I am trying to authorize another sandbox/production to create connection. When I first time authorize the connected app, it is returning the Auhorization Code in the URL, however when it gets redirected to LWC app, code is disappeared because the parameter is 'code' not like 'c__code'. So, pagereference state is unable to read the param value. It was working till the previous release, with Spring release it started behaving differently.  Original URL: not working    I tested with adding 'c__' to the param manually and it worked fine.  Modified URL: Working    is there a way we can rename the redirected URL params dynamically?  'code' to 'c__code'
77120
I am trying to implement  and below is my code and debug log - any help is appreciated.  Http httpProtocol = new Http();    HttpRequest request = new HttpRequest(); request.setHeader('Content-Type', 'application/json;'); request.setEndPoint('https://test.salesforce.com/services/oauth2/token'); request.setMethod('POST'); String strbody = '{"grant_type":"Password", "password":"MY PASSWORD + TOKEN", "username":"SANDBOX USER NAME",  "client_secret":"secret",   "client_id":"Client id from remote setttings"}'; request.setBody(strbody); HttpResponse response = httpProtocol.send(request); String jsonInput = response.getBody(); system.debug('jsonInput===&gt;'+jsonInput);   Debug log -   15:55:38.068 (68324000)|SYSTEM_METHOD_ENTRY|[5]|System.HttpRequest.setMethod(String) 15:55:38.068 (68346000)|SYSTEM_METHOD_EXIT|[5]|System.HttpRequest.setMethod(String) 15:55:38.068 (68350000)|STATEMENT_EXECUTE|[6] 15:55:38.068 (68356000)|HEAP_ALLOCATE|[6]|Bytes:357 15:55:38.068 (68381000)|VARIABLE_ASSIGNMENT|[6]|strbody|"{\"grant_type\":\"Passw (337 more) ..." 15:55:38.068 (68387000)|STATEMENT_EXECUTE|[7] 15:55:38.068 (68407000)|SYSTEM_METHOD_ENTRY|[7]|System.HttpRequest.setBody(String) 15:55:38.068 (68440000)|SYSTEM_METHOD_EXIT|[7]|System.HttpRequest.setBody(String) 15:55:38.068 (68445000)|STATEMENT_EXECUTE|[8] 15:55:38.068 (68478000)|SYSTEM_METHOD_ENTRY|[8]|System.Http.send(APEX_OBJECT) 15:55:38.068 (68568000)|CALLOUT_REQUEST|[8]|System.HttpRequest[Endpoint=https://test.salesforce.com/services/oauth2/token, Method=POST] 15:55:38.483 (483258000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:219 15:55:38.483 (483399000)|CALLOUT_RESPONSE|[8]|System.HttpResponse[Status=Bad Request, StatusCode=400] 15:55:38.483 (483424000)|HEAP_ALLOCATE|[8]|Bytes:96 15:55:38.483 (483444000)|SYSTEM_METHOD_EXIT|[8]|System.Http.send(APEX_OBJECT) 15:55:38.483 (483615000)|VARIABLE_ASSIGNMENT|[8]|response|"System.HttpResponse[Status=Bad Request, StatusCode=400]"|0x1b22c3f1 15:55:38.483 (483627000)|STATEMENT_EXECUTE|[9] 15:55:38.483 (483666000)|SYSTEM_METHOD_ENTRY|[9]|System.HttpResponse.getBody() 15:55:38.483 (483742000)|HEAP_ALLOCATE|[9]|Bytes:81 15:55:38.483 (483751000)|SYSTEM_METHOD_EXIT|[9]|System.HttpResponse.getBody() 15:55:38.483 (483780000)|VARIABLE_ASSIGNMENT|[9]|jsonInput|"{\"error\":\"unsupporte (61 more) ..." 15:55:38.483 (483786000)|STATEMENT_EXECUTE|[10] 15:55:38.483 (483794000)|HEAP_ALLOCATE|[10]|Bytes:13 15:55:38.483 (483980000)|HEAP_ALLOCATE|[10]|Bytes:94 15:55:38.483 (483999000)|SYSTEM_METHOD_ENTRY|[10]|System.debug(ANY) 15:55:38.484 (484025000)|USER_DEBUG|[10]|DEBUG|jsonInput===&gt;{"error":"unsupported_grant_type","error_description":"grant type not supported"}
19990
We are trying to migrate data from one sales force org to other using REST web service. Created REST service in one org trying use that service from other org but getting error "System.HttpResponse[Status=Unauthorized, StatusCode=401]".  Http Callout :  String username = correct usernme; String password = Correct password;  Blob headerValue = Blob.valueOf(username + ':' + password);      String authorizationHeader = 'Basic' +      EncodingUtil.base64Encode(headerValue);  HttpRequest req = new HttpRequest(); req.setEndpoint('https://ap4.salesforce.com/services/apexrest/Accounts/'); //req.setHeader('Authorization', authorizationHeader); req.setMethod('GET'); //req.setHeader('content-type', 'application/json');   req.setTimeout(120000); //req.setBody(jsonBody);                 Http htp = new Http(); HttpResponse resp = htp.send(req);  System.debug('resp:'+resp);   HOw should i call one sales force rest web service from another salesforce org?
53385
While sending an attachment as an email to be attached to the salesforce record.Salesforce is giving the below given error.  Generating server: mx1.madison.gov  6-2j26dncatawfg1112dv2uwxupq9hzfgmjrrlrn2rx48cxm93nt.8-dea8eae.c.le.salesforce.com mx1-asg.mta.salesforce.com # #SMTP#  Is this salesforce problem or it is the Internal company server problem as I could see that error mentions company server name also.But to me doesn't look like company server error.
35256
I am unable to log on to . I receive the following error as soon as I try "Log in using Google". (This is the same Gmail account I use for Stack Exchange.)     'key' is not valid for passed 'access_token', token not found.     On my Android Device (Galaxy S4 4.4.2), I have two Google accounts – will this have an effect, or am I missing a step in order to log on with a Google account using the Stack Exchange Android app?
61310
As part of our CI/CD with Azure, we were able to successfully authorize an Org using the JWT-Based Flow AS LONG AS we follow the steps   Every time we refresh our sandboxes, we have to go through the whole process again, which is a bit of a pain.  Question is, do you guys know if I can generate a server.key file (which is requried by the JWT Flow) from a self-signed certificate created within Salesforce, and not openssl?  Thanks.
77080
This may sound repititve question. But the error incurs after following multiple links found like:  and .  The controller:  public with sharing class SFLoginCtrlr {     public static HTTPResponse getResp(String loginCred){         Map&lt;String, Object&gt; mapLoginCred = (Map&lt;String, Object&gt;)JSON.deserializeUnTyped(loginCred);         String username = ''+mapLoginCred.get('username');         String password = ''+mapLoginCred.get('password');         HttpRequest req = new HttpRequest();         req.setMethod('POST');            req.setTimeout(60000);         req.setEndpoint('https://www.salesforce.com/services/Soap/u/29.0');         req.setHeader('Content-Type', 'text/xml;charset=UTF-8');                 req.setHeader('SOAPAction', '""');         req.setBody('&lt;Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/"&gt;&lt;Header/&gt;&lt;Body&gt;&lt;login xmlns="urn:partner.soap.sforce.com"&gt;&lt;username&gt;' +username+ '&lt;/username&gt;&lt;password&gt;' + password + '&lt;/password&gt;&lt;/login&gt;&lt;/Body&gt;&lt;/Envelope&gt;');                 HttpResponse res = new Http().send(req);         return res;     } }   The mock class:  @isTest global class ExampleCalloutMock implements HttpCalloutMock{   global HttpResponse respond(HTTPRequest req){     HttpResponse res = new HttpResponse();     res.setStatus('OK');     res.setStatusCode(200);     res.setBody('SUCCESS');     return res;   } }   The test class:  @isTest private class SFLoginCtrlrTest{     static testMethod void SFLoginCtrlrTestMethod(){         Test.startTest();          Test.setMock(HttpCalloutMock.class, new ExampleCalloutMock());          Map&lt;String, String&gt; logincred = new Map&lt;String, String&gt;();         logincred.put('username', 'dummy@user.com');         logincred.put('password', 'notapassword');          SFLoginCtrlr.getResp(JSON.serialize(logincred));          Test.stopTest();     } }   The error received while running test class:     Methods defined as TestMethod do not support Web service callouts   Not sure, where is the issue...
56723
Am a bit new to Salesforce, integrating with our existing systems which uses Python, so I'm making use of the . It's working great, except I cannot figure out how you convert a Lead to a Contact/Account via the API. Is there some endpoint to do this?
81675
I am attempting to create a web app (ruby on rails) that requires access to a user's Salesforce environment to perform some REST api calls (SOQL queries) and in doing so I've implemented the . On a dev org I have access to I have created a connected app and am able to successfully connect to that connected app, authorize against it with a user from that environment and then with the returned authorization code I'm able request an access token and make REST calls. However my goal is to allow a salesforce user to authorize access to their org without having a connected app installed in their environment? How is this done?  To look at this same issue from a different perspective, how does a website such as  or  allow a salesforce user to authorize access to their environment?
76864
I configured a Data Extract (Data Extension Extract) and a File Transfer (Safe House to External FTP which is also an SFMC FTP ).  Unfortunately, File Transfer fails without giving a proper error.   ERROR:  An undefined error occurred. Contact your account representative if the error persists.  Salesforce Support is asking me to whitelist Stack 1 IP Address on my Internal Network when the operation is done within SFMC Servers. I have ask them to escalate this to Tier 2 support.    Have you come across this issue in the past? What have you done to resolve this issue?
119593
I have to embed a Metabase Iframe into Salesforce via an lwc.  The metabase itself gives me the code below in Node.js as an example.  var jwt = require("jsonwebtoken"); var METABASE_SITE_URL = "METABASE_SITE_URL"; var METABASE_SECRET_KEY = "15480e3f631b3ff5a1dcfa9d2efdbfc94395e66ecdcc238f2"; var payload = {   resource: { question: 1209 },   params: {},   exp: Math.round(Date.now() / 1000) + (10 * 60) // 10 minute expiration }; var token = jwt.sign(payload, METABASE_SECRET_KEY); var iframeUrl = METABASE_SITE_URL + "/embed/question/" + token + "#bordered=false&amp;titled=false";   Now I am trying to adapt this code to Apex and it has been a really painful journey.  I've tried using JWT class, JWS and Crypto, but so far without success.  There is extensive documentation of people using JWS to connect to Salesforce, but so far I haven't found an example implementation where Token is generated in Salesforce without hitting third party endpoints.  UPDATE  The point is how can I generate a JWT token in apex using only the header, the payload and the key?  UPDATE 2  I finally made it!  String header = '{"alg":"HS256","typ":"JWT"}'; String payload = '{"resource":{"question":1209},"params":{},"exp":1571678680,"iat":1569518680}'; String key = '19bce9bf8c9dc1255480e3f631b3ff5a1dcfa9d2efdbfc94395e66ecdcc238f2';  String header64 = EncodingUtil.base64Encode(Blob.valueOf(header));  header64 = header64.replaceAll('=',''); header64 = header64.replaceAll('-',''); header64 = header64.replaceAll('/','');  String payload64 = EncodingUtil.base64Encode(Blob.valueOf(payload));  payload64 = payload64.replaceAll('=',''); payload64 = payload64.replaceAll('-',''); payload64 = payload64.replaceAll('/','');  Blob hmacData = Crypto.generateMac('hmacSHA256', Blob.valueOf(header64 + '.' + payload64), Blob.valueOf(key));  String signature = EncodingUtil.base64Encode(hmacData);  String token = header64 + '.' + payload64 + '.' + signature; token = token.replaceAll('=',''); token = token.replaceAll('-',''); token = token.replaceAll('/','');
19502
I am using cURL to insert data into salesforce. It works with single record but I need to insert multiple records at a time. Is it possible to do so and is it possible via a REST interface?