I am trying to setup a connection between Xero and Salesforce using oAUth2.0.
I am doing it as per the Xero Documentation mentioned here: https://developer.xero.com/documentation/oauth2/auth-flow
Step 1: To get Authorization Code which is working fine.
Step 2: Make a Post Request to Xero to get access token.
Here is my code:
HttpRequest request = new HttpRequest(); request.setEndpoint('https://identity.xero.com/connect/token'); request.setMethod('POST'); request.setHeader('grant_type','authorization_code'); request.setHeader('Authorization',authorizationHeader); request.setHeader('redirect_uri','my redirect url'); request.setHeader('Content-Type','application/x-www-form-urlencoded'); request.setHeader('code',authCode);
When i am executing it, i am getting 411 as status code and message Length Required.
I have tried to resolve the issue by adding
request.setHeader('Content-Length','32') but now it's throwing Read Timeout issue.
Am i missing something?