Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    Getting "errorCode":"AG8001 while getting historical data

    Test
    0
    5
    9
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      ackshay last edited by

      Error code- {"success":false,"message":"Invalid Token","errorCode":"AG8001","data":""}'

      Getting this error while fetching historical data, I have reset my password and pin also but still getting the same error.

      Although I am able to generate refresh token successfully.

      M 1 Reply Last reply Reply Quote 0
      • M
        Moderator_2 @ackshay last edited by

        Hi @ackshay

        Apologies for delayed response.
        "Invalid Token" represents the expired authorization. Kindly reverify by passing the fresh token after login. If the issue has not resolved, please share us the API request, header passed and response to analyze further.

        Thanks & Regards,
        SmartAPI team

        D 1 Reply Last reply Reply Quote 0
        • D
          daalchawal @Moderator_2 last edited by

          @Moderator_2
          url <- "https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword"

          json_body<-toJSON(list(
          'clientcode'="xxxx",
          'password'='xxxx',
          'totp'='372426'
          ))

          response<-POST(url ="https://apiconnect.angelbroking.com/rest/auth/angelbroking/user/v1/loginByPassword",
          config=list(
          add_headers(
          'Content-Type'= 'application/json',
          'Accept'= 'application/json',
          'X-UserType'= 'USER',
          'X-SourceID'= 'WEB',
          'X-ClientLocalIP'= 'xxxxx',
          'X-ClientPublicIP'= 'xxxx',
          'X-MACAddress'= 'xxxx',
          'X-PrivateKey'= 'xxxx'
          )
          ),body = json_body,
          encode = 'raw')

          M 1 Reply Last reply Reply Quote 0
          • M
            Moderator_2 @daalchawal last edited by

            Hi @daalchawal,

            Apologies for delayed response.
            Kindly write to us with the client details on smartapi@angelbroking.com if the "Invalid Token" still being faced on login API.

            Thanks & Regards,
            SmartAPI team

            1 Reply Last reply Reply Quote 0
            • S
              shovaniam last edited by

              Instead doing it literally strings as provided in documentation

              OkHttpClient client = new OkHttpClient().newBuilder()
                .build();
              MediaType mediaType = MediaType.parse("application/json");
              RequestBody body = RequestBody.create(mediaType,
                   "{\n
                      \"clientcode\":\"CLIENT_ID\",\n
                      \"password\":\"CLIENT_PIN\"\n
              		\"totp\":\"TOTP_CODE\"\n
                  }"
                   );
              

              put it in map to reduce chances of error in json format

                 // Create a Map to represent the JSON structure
                      Map<String, String> requestBodyMap = new HashMap<>();
                      requestBodyMap.put("clientcode", "CLIENT_ID");
                      requestBodyMap.put("password", "CLIENT_PIN");
                      requestBodyMap.put("totp", "TOTP_CODE");
              
                      // Convert the Map to JSON
                      ObjectMapper objectMapper = new ObjectMapper();
                      byte[] requestBodyBytes = objectMapper.writeValueAsBytes(requestBodyMap);
              
                      // Create the request body
                      RequestBody body = RequestBody.create(mediaType, requestBodyBytes);
              
              
              1 Reply Last reply Reply Quote 1
              • First post
                Last post