简体   繁体   中英

Tafilate REST API using c#

We developed Asp.Net MVC application and now we wants to integrate tapfiliate in the same. We are done up to Customer creation and we wants to do Conversions against those customer.we could create customer using JS. But scheduler program going to take decision for conversion of customer depending on some criteria so we need to use tapfiliate's REST API as this call being through Asp.Net class library. We tried below code to achieve this but we are getting Forbidden access denied error.

public async Task<String> CreateConversion()
       {
           string Status = string.Empty;
           using (var client = new HttpClient())
           {
               client.BaseAddress = new Uri("https://api.tapfiliate.com");
               client.DefaultRequestHeaders.Accept.Clear();
               client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
               //New code:
               HttpResponseMessage response = await client.GetAsync("/1.6/conversions/");
               if (response.IsSuccessStatusCode)
               {
                   Status = "Success";
               }
           }
           return Status;
       }

Anybody knows how to make call to REST API for Conversions action through Asp.Net c#?

您应该为 HttpClient 配置 api 密钥

client.DefaultRequestHeaders.Add("Api-Key", yourApiKey);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM