how to pass a list of data table via api which should send token in header.

fahime abouhamze 126 Reputation points
2021-09-29T05:19:08.397+00:00

hi I've tried the code bellow

     public Response SendContract(ContractRequest contractModel, string token)
    {
        Response data = null;
        string baseAddress = "https://auth.services.centinsur.ir/api/Contract/Insert";
        int Error = 0;
        BLL.BLLResponse bLLResponse = new BLL.BLLResponse();
        BLL.BLLRequest bLLRequest = new BLL.BLLRequest();

        string ResponseText = "";
        Response response = new Response();


        using (HttpClient Client = new HttpClient())
        {
            try
            {
                Client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);
                Dictionary<string, string> parameters = new Dictionary<string, string>();
                parameters.Add("Id", contractModel.Id);
                parameters.Add("IssueDate", contractModel.IssueDate);
                parameters.Add("BeginDate", contractModel.BeginDate);
                parameters.Add("EndDate", contractModel.EndDate);
                parameters.Add("Count", contractModel.Count);
                parameters.Add("Amount", contractModel.Amount);
                parameters.Add("PersonCode", contractModel.PersonCode);
                parameters.Add("Name", contractModel.Name);
                parameters.Add("LastName", contractModel.LastName);
                parameters.Add("NationalCode", contractModel.NationalCode);
                parameters.Add("ContractId", contractModel.ContractId);
                parameters.Add("ExternalNumber", contractModel.ExternalNumber);

                var content = new FormUrlEncodedContent(parameters);
                var response1 = Client.PostAsync(baseAddress, content).Result;
                if (response1.IsSuccessStatusCode)
                {


                }

            }
            catch
            {

            }

         }

            return response;

    }

but I think because of the number of records is high it is not the best practice ?

Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
316 questions
0 comments No comments
{count} votes