You need to sign in to do that
Don't have an account?
REST - Update from SF to SF
I have a named credential and finally have the two SF orgs connected with the connected app feature. Now I want to do a simple update to a user record with a REST call but I get a 400 error. I am very new to integration and REST and was hoping for some direction....
HttpRequest req = new HttpRequest();
req.setEndpoint('callout:Sandbox_Management/services/data/v40.0/sobjects/User/0056A000001jCnC?_HttpMethod=PATCH');
req.setMethod('POST');
Http http = new Http();
req.setHeader('Content-Type', 'application/json;charset=UTF-8');
req.setBody('{"isActive":false}');
req.setBody('{"id" : "0056A000001jCnC", "isActive":false}');
HTTPResponse res = http.send(req);
System.debug('SENT');
System.debug(res.getBody());
GOT THIS BACK:
18:46:56:053 USER_DEBUG [20]|DEBUG|[{"errorCode":"URL_NOT_RESET","message":"Destination URL not reset. The URL returned from login must be set"}]
Your endpoint is wrong, if you are accessing sandbox then use this - https://test.salesforce.com/services/data/v40.0/sobjects/User/0056A000001jCnC
If you are accessing production/developer org then use this - https://login.salesforce.com/services/data/v40.0/sobjects/User/0056A000001jCnC
If this answer solves your problem then mark it as the solution to help others. Thanks.
This POC is developer or to developer org. So for that case, woudn't the URL be correct? Are you saying if I am referencing the "my domain" change it to login.salesforce.com? Where would I change that, the Named Credential, Connected App, or oAuth Provider if that is what you are saying?
Thanks