update ApiService::foreignCall() function