3

Please help me, I'm so stuck on this problem: I'm making an request BSCSCAN-API-TESTNET with Axios on React Native and the request is working correctly only within the iOS, but it is not working with the Android (403 Forbidden response).

My URL request: https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5 I updated the apiKey so don't mind it.

My code: (IOS: oke, android: throw error 403)

try {
  const url =
    'https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5';
  const response = await axios.get(url);
} catch (error) {
  throw error;
}
Kartikey
  • 4,516
  • 4
  • 15
  • 40
VuongLQ
  • 31
  • 2

1 Answers1

4

Setting the user agent helped me solve the 403 issue.

try {
      const url =
        'https://api-testnet.bscscan.com/api?module=account&action=txlist&address=0x400ee0c820144c8bb559ace1ad75e5c13e750334&sort=desc&apikey=P3A263376TPJHKQ5IXUD4VHUNFQKDJB4G5';
      const response = await axios.get(url, {headers: { "User-Agent": "Mozilla/5.0" }});
    } catch (error) {
      throw error;
    }
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 16 '21 at 07:41
  • Man.. your answer saved my sanity! But do you know why this help? – eMko Aug 25 '23 at 13:36