You need to sign in to do that
Don't have an account?
Hardik Chavda
When I call the code from the source org. It sends the request but in response it gives me back this error : System.HttpResponse[Status=Bad Request, StatusCode=400],
I even tried using SOAP UI, It shows me the following error.
I also went to critical updates and activate the TLS 1.1, Can anyone please help me with this?
Thanks in advance.
Getting this error : System.HttpResponse[Status=Bad Request, StatusCode=400]
Hi,
I am actually new to REST api and tried one simple example by connecting 2 salesforce org. Following is the snippet of my code.
Source Org Class.
public class RestServiceCalloutController{ public void CalloutRest(){ try{ HttpRequest req = new HttpRequest(); req.setEndpoint('https://ap2.salesforce.com/services/apexrest/TestAccount'); req.setMethod('POST'); String authorizationHeader = 'Bearer '+SessionId; //put the sessionId manually from the destination org. req.setHeader('Authorization', authorizationHeader); //req.setHeader('Content-Type', 'application/json'); system.debug('*******REQ'+req); Http http = new Http(); HTTPResponse res = http.send(req); system.debug('*******Res'+res); } catch(exception e){ system.debug('--------EXCEPTION-----'+e); } } }Destination Org Class.
@RestResource(urlMapping='/TestAccount/*') global class TestRestApi{ @HttpPost global static void TestRest(){ system.debug('Caaling'); } }
When I call the code from the source org. It sends the request but in response it gives me back this error : System.HttpResponse[Status=Bad Request, StatusCode=400],
I even tried using SOAP UI, It shows me the following error.
I also went to critical updates and activate the TLS 1.1, Can anyone please help me with this?
Thanks in advance.
Create site in your sales force account of which is havingrest class .
replace
req.setEndpoint('yoursiteurl/services/apexrest/TestAccount');
give a acees to class for site profile ,
it will work .
Regads,
Harish.R.