Created
July 14, 2021 15:36
-
-
Save thukuwanjiku/bd991befd24cbfd835b052ab1c56696f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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