如何从类库C#中的类进行http调用?
发布时间:2020-12-15 22:44:19 所属栏目:百科 来源:网络整理
导读:我正在使用C#中的Quartz库编写Job Scheduler.我的要求是如果满足业务条件,我需要打电话给Apple服务器. 这就是我的Scheduler的样子: – public class CustomerJob : BaseJob{ private readonly ICustomerSchedulerService _customerSchedulerService; public
我正在使用C#中的Quartz库编写Job Scheduler.我的要求是如果满足业务条件,我需要打电话给Apple服务器.
这就是我的Scheduler的样子: – public class CustomerJob : BaseJob { private readonly ICustomerSchedulerService _customerSchedulerService; public CustomerJob (ICustomerSchedulerService customerSchedulerService) { _customerSchedulerService= customerSchedulerService; } public override void Execute(IJobExecutionContext context) { var customers = _customerSchedulerService.CheckExpiredTask(); foreach(var customer in customers) { //I need to make a post request to apple server for each customer //something like below however there is no HttpClient() available in this class //var client = new HttpClient(); //client.PostAsync("https://sandbox.itunes.apple.com/verifyReceipt",customer)); } base.Execute(context); } } 那么如何解决这个要求? 注意:- 谢谢. 解决方法
如果你的班级没有,你可能只需要在顶部添加一个参考或稍微更改你的线路.
替换新的HttpClient();使用新的System.Net.Http.HttpClient();.这应该工作或Visual Studio(如果这是你正在使用的)应该告诉你潜在的修复:) 希望这有帮助,如果没有回复,我可能能够确定你的下一个问题:) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |