xcrun altool --upload-app is not working

I am trying to upload ipa to App Store Connect using altool but it is always giving this 401 error. There is no issue with the Api key as it works for other commands with altool such as --list-apps etc

2024-07-17 11:26:38.411 *** Error: ERROR: [ContentDelivery.Uploader] REQUEST CREATE CONTAINER (ASSET_UPLOAD): failed to authenticate. The server response was: { errors = ( { code = "NOT_AUTHORIZED"; detail = "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"; status = 401; title = "Authentication credentials are missing or invalid."; } ); } 2024-07-17 11:26:38.412 *** Error: ERROR: [ContentDelivery.Uploader] REQUEST CREATE CONTAINER (ASSET_UPLOAD): received status code 401, auth issue. 2024-07-17 11:26:38.413 *** Error: Error uploading '/.ipa'. 2024-07-17 11:26:38.414 *** Error: Unable to authenticate. (-19209)

xcrun altool --upload-app is not working
 
 
Q