Murray Brown
asked on
ASP.net POST Xero Invoice
In Visual Studio ASP.net C# I have used the first bit of code before to send information via an API
The second bit of code is an example of how to send an invoice to the Xero accounting system.
How I merge the two to send an invoice to Xero from a C# project
The second bit of code is an example of how to send an invoice to the Xero accounting system.
How I merge the two to send an invoice to Xero from a C# project
public string PostEmployeeHoursEdit(List<LineEdit> DataLines, int StoreID)
{
HttpWebResponse Resp;
try
{
string url = "http://www.restaurantmagicbox.com/platform/api/";
string API_Method = "EmployeeHours";
string data = "";
data = Newtonsoft.Json.JsonConvert.SerializeObject(DataLines);
string Auth = this.txtUsername.Text + ":" + this.txtPassword.Text;
string webAddress = url + API_Method + "/" + StoreID + "/0";
HttpWebRequest request = HttpWebRequest.Create(webAddress);
request.Method = WebRequestMethods.Http.Post;
request.Headers.Add("Authorization", Auth);
request.ContentType = "application/json";
request.ContentLength = data.Length;
StreamWriter writer = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
writer.Write(data);
writer.Close();
Resp = request.GetResponse();
Stream stream = request.GetResponse().GetResponseStream();
StreamReader reader = new StreamReader(stream);
string response = reader.ReadToEnd();
return "OK";
}
catch (WebException wex)
{
WebResponse response = wex.Response;
HttpStatusCode statusCode;
HttpWebResponse httpResponse = (HttpWebResponse)response;
statusCode = httpResponse.StatusCode;
return statusCode + " " + httpResponse.StatusDescription;
}
}
{
"Type": "ACCREC",
"Contact": {
"ContactID": "eaa28f49-6028-4b6e-bb12-d8f6278073fc"
},
"Date": "\/Date(1518685950940+0000)\/",
"DueDate": "\/Date(1518685950940+0000)\/",
"DateString": "2009-05-27T00:00:00",
"DueDateString": "2009-06-06T00:00:00",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"Description": "Consulting services as agreed (20% off standard rate)",
"Quantity": "10",
"UnitAmount": "100.00",
"AccountCode": "200",
"DiscountRate": "20"
}
]
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER