Uniswap - Error while trying to find estimate gas for swapExactTokensForETH and swapExactTokensForTokens

:1234: Code to reproduce

I am trying to find estimate gas while trading in Uniswap.
For ETH-TOKEN or TOKEN-TOKEN transactions, i am using estimateGas() to find the gas limit and doing the calculation.
However i am getting the following error in doing so.

> inputData = await contract.methods.swapExactTokensForETH(amountInUpdatedHex, amountOutMinUpdatedHex, path, to, deadline).encodeABI();
> value = 0;
>                       / GAS ESTIMATE START/
>                       let gasLimit2 = await web3.eth.estimateGas({
>                         "to"        : ROUTER02_ADDRESS_UNISWAP,
>                         "from"      : to,
>                         "nonce"     : nonce + 1,
>                         "data"      : inputData,
>                         "value"     : value
>                     })
>                     console.log('Gas LImit Transaction', gasLimit2);
>                     / GAS ESTIMATE END/
> ```


Error: Returned error: execution reverted: TransferHelper: TRANSFER_FROM_FAILED

I am aware that this error happens when approve is not called. I am confused becoz i am only trying to find the estimate gaslimit for the swapExactTokensForETH/swapExactTokensForTokens functions.

If i am giving a constant value for gasLimit based on the recent transactions, i can successfully swap the tokens. So the question is about finding the estimate.

Any help is really appreciated!

#### 💻 Environment

I am using Uniswap SDK to swap between tokens. 

<!-- Tell us what you're using including versions: Truffle, Hardhat, Remix, etc. -->