Skip to content

Instantly share code, notes, and snippets.

@thukuwanjiku
Created July 14, 2021 15:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thukuwanjiku/bd991befd24cbfd835b052ab1c56696f to your computer and use it in GitHub Desktop.
Save thukuwanjiku/bd991befd24cbfd835b052ab1c56696f to your computer and use it in GitHub Desktop.
using LG_API.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using System.Web.Script.Serialization;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Web;
using System.IO;
namespace LG_API.Controllers
{
public class SalesController : ApiController
{
[Route("api/getSales")]
[HttpGet]
public JObject getSaleRecords()
{
string resp = "";
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://lg-uat.sandbox.operations.dynamics.com/data/LGSalesOrders");
httpWebRequest.Method = AppConstants.GET;
httpWebRequest.ContentType = "application/x-www-form-urlencoded";
httpWebRequest.Headers.Add("Authorization", "Bearer " + General.get_token()); //get_token() is a method in some Helpers class
using (HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
resp = reader.ReadToEnd();
}
var actual_response = JObject.Parse(resp);
//string sales = actual_response["value"];
//var json = JsonConvert.SerializeObject(cashiers);
//return json;
return actual_response;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment