Changed API request method from curl to stream context