refactored API request formatting