-
What's New
Shein
Temu
TikTok Shop
Split Order
Tags and All Unshipped page
Amazon Carrier
OrderTags
Review OrderHelp Topics
Expand all | Collapse all
C# Example
Function:
The main function of this example is to push an order to the teapplix system via the OrderNotification interface.
Interface:
https://api.teapplix.com/api2/OrderNotification
Program development environment:
The development environment of the sample program is Visual studio .NET 2015 C # .
Published Date:
2017/6/12
Push the order of the json string as follows:
{ "Operation": "Submit", "Orders": [ { "TxnId": "EV201705111541CN", "PaymentStatus": "Completed", "To": { "Name": "John", "Company": "xxx", "Street": "xxxxxx", "Street2": "", "State": "CA", "City": "Culver City", "ZipCode": "xxxxxxxxxx", "CountryCode": "US", "PhoneNumber": "xxxxx", "Email": "fake@teapplix.com" }, "OrderTotals": { }, "OrderDetails": { }, "OrderItems": [ { "Name": "Camera", "ItemId": "1", "Quantity": 2 } ] } ] } The organization of the program is shown in the figure
The .NET console program example is as follows
1、.NET reference is required as follows
2、XXXXXXXXXXXXXXXXXXX on behalf of the APIToken value, you can logon Teapplix in the SETUP-API menu obtained.
The HttpClientHelp.cs program is as follows
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Policy;
using System.Threading.Tasks;
using System.Web;
namespace WebApp.Utility
{
public class HttpClientHelp
{
public static readonly HttpClient _httpClient = null;
static HttpClientHelp()
{
_httpClient = new HttpClient();
}
public static async Task<string> OrderNotification()
{
string json = "{\"TrackingInfo\": [{\"TrackingNumber\": \"9400109898642001965566\",\";
json=json+"CarrierName\":\"USPS\"}],";
json = json + "\"PostageAmount\": {\"Amount\": 2.61,\"Currency\": \"USD\"}";
json=json+",\"LabelData\": [{\"Type\": \"URL\",\"Content\":";
json = json + "\"https://api.teapplix.com/api2/DownloadLabel/xxxx/IB14950528862877/pdf\"}],";
json=json+"\"Success\": true,";
json=json+"\"Message\": \"Label was purchased.\",\"Provider\": \"\"}";
var requestUri = "https://api.teapplix.com/api2/OrderNotification";
if (requestUri.StartsWith("https"))
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpContent httpContent = new StringContent(postJson);
httpContent.Headers.Add("ContentType", "application/json");
httpContent.Headers.Add("APIToken", "XXXXXXXXXXXXXXXXXXX");
if (requestUri.StartsWith("https"))
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
try
{
var response = await _httpClient.PostAsync(requestUri, httpContent);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync();
}
catch (AggregateException)
{
return null;
}
}
}
}
The program.cs program is as follows:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WebApp.Utility;
using System.Net.Http;
using System.Runtime.Serialization.Json;
using System.Web.Script.Serialization;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//This function is to push order to teapplix
PushOrderToTeapplix();
}
private static void PushOrderToTeapplix()
{
var result = HttpClientHelp.OrderNotification().Result;
Console.WriteLine("Push order completed!");
}
}
}