Related
I am using the Mailchimp template to send emails through Mandrill. Email being sent successfully. But the variables are not rendering. I tried lots of settings but unfortunately, it is not working. My code is looking like the following.
<p>Dear {{customerName}},</p>
<p>Thank you for using XXXXX to process your return.</p>
<p>All you have to do is bring your parcel along with this e-mail to {{pudoLocation}} at {{emailPudoAddress}}.</p>
And In the Email output, it is showing like this.
And My request JSON to API https://mandrillapp.com/api/1.0/messages/send-template.json is:-
valid json is `{
"key": "xxxxxxxxxxxxxxx",
"template_name": "TestTemplate",
"template_content": [],
"message": {
"subject": "TestEmail",
"from_email": "xxx.xx#xxxxx.in",
"from_name": "Drop2Shop",
"to": [{
"Email": "xxxxx.xxx#xxxxxx.in",
"Name": "Amrit Pannu",
"Type": "to"
}],
"headers": {
"Reply-To": "xxxxx.xxx#xxxx.in"
},
"important": false,
"track_clicks": true,
"track_opens": true,
"merge_language": "handlebars",
"global_merge_vars": [{
"name": "pudoLocation",
"content": "TRK00000028"
},
{
"name": "customerName",
"content": "TRK00000028"
}],
"tags": [""]
}
}`
Please can someone help me here what I missing in this?
Thanks and Advance
You can pass global variables in mandrill using *|VAR1|*. To pass array you can use {{handlebars}}.
The content will be like this:
<p>Dear *|customerName|*,</p>
<p>Thank you for using XXXXX to process your return.</p>
<p>All you have to do is bring your parcel along with this e-mail to *|pudoLocation|* at *|emailPudoAddress|*.</p>
The JSON should be like this only:
{
"key": "XXXXXXXXXXXXXXX",
"template_name": "XXXXXXXXXXXXXXXXXX",
"template_content": [],
"message": {
"subject": "TestEmail",
"from_email": "xxxx#xxxxxxxxxxx.in",
"from_name": "xxxxxx",
"to": [
{
"email": "xxxx#xxxxxxxxxxx.in",
"name": "xxxxx xxxxx",
"type": "to"
}
],
"headers": {
"reply_to": "xxxx.xxxx#xxxx.in"
},
"important": false,
"track_opens": true,
"track_clicks": true,
"merge_language": "handlebars",
"global_merge_vars": [
{
"name": "trackingNumber",
"content": "TRK00000028"
},
{
"name": "customerName",
"content": "Amrit Pannu"
},
{
"name": "eCommerceRetailer",
"content": "Jojo Retailer"
},
{
"name": "goodsDescription",
"content": "Tricycles, Scooters, and Similar Wheeled Toys; Dolls' Carriages"
},
{
"name": "shippingDate",
"content": "2021-07-07"
},
{
"name": "numberOfPackages",
"content": "45"
},
{
"name": "shipFromAddress",
"content": "IRELAND"
},
{
"name": "shipToAddress",
"content": "Britain"
},
{
"Name": "pudoAddress",
"Content": "USA"
},
{
"name": "shipFromContact",
"content": "Commin"
},
{
"name": "shipToContact",
"content": "Stark"
},
{
"name": "customerReference",
"content": "DF7889FSDHCB"
},
{
"name": "pudoLocation",
"content": "Denmark"
},
{
"name": "emailPudoAddress",
"content": "amrit#mailinator.com"
},
{
"name": "unsubscribePageUrl",
"content": ""
},
{
"name": "email",
"content": "amrit#mailinator.com"
},
{
"name": "scanEventTime",
"content": "12:07"
},
{
"name": "scanEventDate",
"content": "07 July 2021"
},
{
"name": "packageItems",
"content": [
{
"GoodsDescription": "869c6f67-f33d-4b30-a274-79b635d12461",
"ReturnReason": "c3b4b071-7664-4060-a39f-52c24147a1ce",
"Quantity": 3,
"Value": 6
},
{
"GoodsDescription": "5e2c625b-74e6-4e90-bb52-6595e9f3d088",
"ReturnReason": "f0949b28-f9a7-406e-8676-b8ce6c714509",
"Quantity": 3,
"Value": 14
},
{
"GoodsDescription": "cffe036a-2441-41af-82e1-130f9169924b",
"ReturnReason": "f31956b9-c24e-492e-b11f-4b4e19489b13",
"Quantity": 1,
"Value": 5
},
{
"GoodsDescription": "f8f64467-6926-4f08-9d4e-aa924dc1af35",
"ReturnReason": "d1f759b0-8e54-4119-94ee-6afe1bc49766",
"Quantity": 4,
"Value": 0
},
{
"GoodsDescription": "496f4e0e-739d-4fce-8a37-85113f27c4d4",
"ReturnReason": "b8d98439-928f-4e6c-bb56-01e6f8fb6be6",
"Quantity": 2,
"Value": 5
},
{
"GoodsDescription": "afe2986c-e51e-4cfe-9506-f9ef2afa5657",
"ReturnReason": "4e6e34f6-d921-46fb-8f4a-b04afd0856a7",
"Quantity": 4,
"Value": 12
},
{
"GoodsDescription": "13ac561a-d161-46a5-9795-8481e99a3afd",
"ReturnReason": "73f4441b-dcff-4f68-a58e-320a29a167c8",
"Quantity": 1,
"Value": 7
},
{
"GoodsDescription": "135e083b-0408-4445-9a0c-3656a46f7eab",
"ReturnReason": "325c7144-8f7d-4712-b708-1702416ca02c",
"Quantity": 2,
"Value": 13
},
{
"GoodsDescription": "ee510bfd-58ea-4707-9c52-26913b190b27",
"ReturnReason": "854629a5-289b-46c9-a072-099e2a572307",
"Quantity": 4,
"Value": 12
},
{
"GoodsDescription": "b6d6fa6e-a327-4014-b019-0c4cd0098da6",
"ReturnReason": "02394799-761c-46f0-af79-d8bc92b2c1b5",
"Quantity": 1,
"Value": 13
}
]
},
{
"name": "currentYear",
"content": 2021
}
],
"tags": null,
"inline_css": true
}
For more information, please see this: https://mailchimp.com/developer/transactional/docs/templates-dynamic-content/#dynamic-content
I'm probably too late, but if it can help someone else.
It's not working because you have to remove all the backslashes Mailchimp added when send it to Mandrill before your variables. Change : \{{customerName}} to {{customerName}}
I am making some mistake in returning data from c# to angular controller,Here is my C# code
public ActionResult FlightDisp()
{
dynamic parsedJson = "";
string myJsonResponse = "";
try
{
const string URL = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
string token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxx";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(URL);
client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + token);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "");
Task<HttpResponseMessage> response = client.SendAsync(request);
myJsonResponse = Newtonsoft.Json.JsonConvert.DeserializeObject(response.Result.Content.ReadAsStringAsync().Result).ToString();
JObject jsonObject = JObject.Parse(myJsonResponse);
parsedJson = JsonConvert.DeserializeObject(myJsonResponse);
}
catch (Exception ex)
{
}
return Json( parsedJson );
}
Whatever i get is parsed json is perfect but when i pass the parsedJson from c# to angular controller it becomes something like:
[
[
[
[
[
[]
],
[
[
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[
[
[]
],
[
[]
]
]
],
[
[
[
[
[]
]
],
[
[]
],
[
[]
],
[
[]
],
[
[]
]
]
],
[
[
[
[]
],
[
[]
],
[
[]
]
]
],
[
[
[
[]
],
[
[]
]
]
],
[
[
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[],
[]
]
]
]
],
[
[]
],
[
[
[
[
[]
],
[
[]
],
[
[]
],
[
[]
],
[
[
[
[]
],
[
[]
]
]
],
[
[
[
[]
],
[
[
[
[]
],
[
[]
]
]
]
Its completely empty but parsedJson has value :
{{
"data": [
{
"type": "hotel-offers",
"hotel": {
"type": "hotel",
"hotelId": "ALNYC647",
"chainCode": "AL",
"dupeId": "501447323",
"name": "Aloft Manhattan Downtown - Financial District",
"rating": "4",
"cityCode": "NYC",
"latitude": 40.71041,
"longitude": -74.00666,
"hotelDistance": {
"distance": 0.4,
"distanceUnit": "KM"
},
"address": {
"lines": [
"49 53 ANN STREET"
],
"postalCode": "10038",
"cityName": "NEW YORK",
"countryCode": "US",
"stateCode": "NY"
},
"contact": {
"phone": "+1 212 513-0003",
"fax": "+1 212 513-0004",
"email": "info#aloftmanhattandowntown.com"
},
"description": {
"lang": "en",
"text": "Celebrate your style at Aloft Manhattan Downtown - Financial District, a hip new hotel where you'll be close to corporate headquarters, Wall Street and the World Trade Center. We offer easy-breezy access to Big Apple hotspots via nearby subway lines. Meet & mingle with friends at our w xyz(SM) bar, grab a sweet, savory or healthy snack from re:fuel by Aloft(SM), our 24/7 pantry or play in our re:mix(SM) lounge. Plus, you can always stay connected with free hotel-wide wired and wireless High Speed Internet Access! Breeze into one of our Aloft rooms, featuring our ultra-comfortable signature bed, walk-in shower, custom amenities by Bliss® Spa and more."
},
"amenities": [
"SPA",
"SERV_DOGS_ALWD",
"ACC_TOILETS",
"HANDRAIL_BTHRM",
"24_HOUR_FRONT_DESK",
"CAR_RENTAL",
"EXPRESS_CHECK_IN",
"LOUNGE",
"ICE_MACHINES",
"FLORIST",
"TRAVEL_AGENCY",
"CONCIERGE",
"SAFE_DEP_BOX",
"LAUNDRY_SVC",
"ATM/CASH_MACHINE",
"EXPRESS_CHECK_OUT",
"WEDDING_SERVICES",
"GYM",
"RESTAURANT",
"HI_INTERNET",
"FREE_INTERNET",
"WIRELESS_CONNECTIVITY",
"ELEVATOR",
"PETS_ALLOWED",
"PHOTOCOPIER",
"PRINTER",
"BUSINESS_CENTER",
"MEETING_FACILITIES",
"INTERNET-HI_SPEED_IN_RM",
"WI-FI_IN_ROOM",
"NONSMOKING_RMS",
"FREE_LOCAL_CALLS",
"TEA/COFFEE_MK_FACILITIES",
"ALARM_CLOCK",
"AIR_CONDITIONING",
"SAFE",
"IRON/IRON_BOARD",
"CRIBS_AVAILABLE",
"TELEVISION",
"HAIR_DRYER",
"VOICEMAIL_IN_ROOM",
"PHONE-DIR_DIAL",
"CORDLESS_PHONE",
"REFRIGERATOR",
"OUTLET_ADAPTERS",
"CABLE_TELEVISION",
"FITNESS_CENTER"
]
},
"available": true,
"offers": [
{
"id": "LBRB9R0B0X",
"checkInDate": "2020-09-13",
"checkOutDate": "2020-09-14",
"rateCode": "S9R",
"rateFamilyEstimated": {
"code": "SRS",
"type": "C"
},
"room": {
"type": "XMI",
"typeEstimated": {
"beds": 1,
"bedType": "QUEEN"
},
"description": {
"lang": "EN",
"text": "Marriott Senior Discount, includes 62 years and older valid ID \nSleeps 2, Fast & free WiFi throughout the hotel\n, 1 Queen, 200sqft/18sqm-220sqft/20sqm, Wireles"
}
},
"guests": {
"adults": 1
},
"price": {
"currency": "USD",
"base": "127.00",
"total": "149.25",
"variations": {
"average": {
"base": "127.00"
},
"changes": [
{
"startDate": "2020-09-13",
"endDate": "2020-09-14",
"base": "127.00"
}
]
}
},
"policies": {
"paymentType": "guarantee",
"cancellation": {
"deadline": "2020-09-13T09:29:00+05:30"
}
}
}
],
"self": "https://test.api.amadeus.com/v2/shopping/hotel-offers/by-hotel?hotelId=ALNYC647"
},
{
"type": "hotel-offers",
"hotel": {
"type": "hotel",
"hotelId": "HXNYC432",
"chainCode": "HX",
"dupeId": "700051862",
"name": "HAMPTON INN MANHATTAN-DOWNTOWN-FINANCIAL",
"rating": "2",
"cityCode": "NYC",
"latitude": 40.70312,
"longitude": -74.01228,
"hotelDistance": {
"distance": 1.3,
"distanceUnit": "KM"
},
"address": {
"lines": [
"32 PEARL ST"
],
"postalCode": "10004",
"cityName": "NEW YORK",
"countryCode": "US",
"stateCode": "NY"
},
"contact": {
"phone": "1-212-480-3500",
"fax": "1-212-480-3700"
},
"amenities": [
"BUSINESS_CENTER",
"ADAPTED_PHONES",
"WIDE_ENTRANCE",
"WIDE_CORRIDORS",
"FIRST_AID_STAF",
"INT_ROOM_ENTRY",
"EMERG_LIGHTING",
"FIRE_DETECTORS",
"EXTINGUISHERS",
"FIRE_SAFETY",
"RESTRIC_RM_ACC",
"SMOKE_DETECTOR",
"SPRINKLERS",
"LAUNDRY_SVC",
"PARKING",
"PETS_ALLOWED",
"SAFE_DEP_BOX",
"AIR_CONDITIONING",
"HAIR_DRYER",
"MOVIE_CHANNELS",
"NONSMOKING_RMS",
"PC_HOOKUP_INRM",
"TELEVISION",
"FITNESS_CENTER"
],
"media": [
{
"uri": "http://uat.multimediarepository.testing.amadeus.com/cmr/retrieve/hotel/9E95CFEC3B6F4C459EDC0F267159B799",
"category": "EXTERIOR"
}
]
},
"available": true,
"offers": [
{
"id": "Y0IT2BLO9V",
"checkInDate": "2020-09-13",
"checkOutDate": "2020-09-14",
"rateCode": "RAC",
"rateFamilyEstimated": {
"code": "AAA",
"type": "C"
},
"commission": {
"percentage": "10.00"
},
"boardType": "BREAKFAST",
"room": {
"type": "C1Q",
"typeEstimated": {
"category": "ACCESSIBLE_ROOM",
"beds": 1,
"bedType": "QUEEN"
},
"description": {
"lang": "EN",
"text": "AAA RATE\n1 QUEEN ACCESSIBLE ROLL IN SHOWER NONSMOKING\nHDTV/WORK AREA"
}
},
"guests": {
"adults": 1
},
"price": {
"currency": "USD",
"base": "594.15",
"total": "685.29",
"variations": {
"average": {
"base": "594.15"
},
"changes": [
{
"startDate": "2020-09-13",
"endDate": "2020-09-14",
"base": "594.15"
}
]
}
},
"policies": {
"paymentType": "guarantee",
"cancellation": {
"deadline": "2020-09-10T09:30:00+05:30"
}
}
}
],
"self": "https://test.api.amadeus.com/v2/shopping/hotel-offers/by-hotel?hotelId=HXNYC432"
},
{
"type": "hotel-offers",
"hotel": {
"type": "hotel",
"hotelId": "BWNYC133",
"chainCode": "BW",
"dupeId": "700101379",
"name": "Best Western Bowery Hanbee Hotel",
"rating": "2",
"cityCode": "NYC",
"latitude": 40.7184,
"longitude": -73.99518,
"hotelDistance": {
"distance": 1.0,
"distanceUnit": "KM"
},
"address": {
"lines": [
"231 GRAND STREET"
],
"postalCode": "10013",
"cityName": "NEW YORK CITY",
"countryCode": "US",
"stateCode": "NY"
},
"contact": {
"phone": "+1 212 9251177",
"fax": "+1 212 9255533",
"email": "33133#hotel.bestwestern.com"
},
"description": {
"lang": "en",
"text": "Stay at this 100% non-smoking New York City, New York hotel located next to the subway and key local attractions such as Canal Street, Chinatown and Little Italy. Welcome to the Best Western Bowery Hanbee Hotel, where guests will find exceptional customer service and accommodations at an affordable rate. This New York City hotel features well-appointed guest rooms and suites, each offering cable satellite television with free HBO® and free wireless high-speed Internet access. Guests staying at this 100% non-smoking hotel will enjoy a complimentary hot breakfast buffet each morning before heading out to sightsee. Additional amenities include an exercise facility and a full-service business center. The Best Western Bowery Hanbee Hotel is ideally located less than one mile from many New York attractions including Chinatown, Little Italy, the Wall Street financial district and the World Trade Center Memorial. Hotel guests will enjoy an afternoon of shopping on 5th Avenue or visiting key sights such as Ellis Island, the Statue of Liberty, the Empire State Building and Times Square. Corporate travelers will appreciate being a half mile from the New York Stock Exchange, the Federal Reserve Bank, JP Morgan and American Express®. This New York hotel is also ideal for viewing several annual events including the Macy's Thanksgiving Day Parade®, the Chinese New Year and the Tribeca Film Festival. The friendly, helpful staff at the Best Western Bowery Hanbee Hotel is ready to ensure a fun-filled memorable stay in New York, New York. Make a reservation today and save! Enjoy your stay!"
},
"amenities": [
"24_HOUR_FRONT_DESK",
"GYM",
"HI_INTERNET",
"ELEVATOR",
"ICE_MACHINES",
"SPRINKLERS",
"FIRE_DETECTORS",
"FEMA_FIRE_SAFETY_COMPLIANT",
"SMOKE_DETECTOR",
"EMERG_LIGHTING",
"HANDICAP_FAC",
"BUSINESS_CENTER",
"FREE_LOCAL_CALLS",
"PHONE-DIR_DIAL",
"INTERNET-HI_SPEED_IN_RM",
"HAIR_DRYER",
"AIR_CONDITIONING",
"CABLE_TELEVISION",
"VOICEMAIL_IN_ROOM",
"SAFE",
"WAKEUP_SERVICE",
"ALARM_CLOCK",
"TEA/COFFEE_MK_FACILITIES",
"CRIBS_AVAILABLE"
],
"media": [
{
"uri": "http://uat.multimediarepository.testing.amadeus.com/cmr/retrieve/hotel/A15115741A8747538ECDBB2AA76B7DE9",
"category": "EXTERIOR"
}
]
},
"available": true,
"offers": [
{
"id": "MLX8YR77R7",
"checkInDate": "2020-09-13",
"checkOutDate": "2020-09-14",
"rateCode": "SRS",
"rateFamilyEstimated": {
"code": "SRS",
"type": "C"
},
"commission": {
"percentage": "10"
},
"boardType": "BREAKFAST",
"room": {
"type": "A1Q",
"typeEstimated": {
"category": "ACCESSIBLE_ROOM",
"beds": 1,
"bedType": "QUEEN"
},
"description": {
"lang": "EN",
"text": "SENIOR RATE*CITIZENS 55YRS PLUS OR AARP ID\n1 QUEEN BED,MOBILITY ACC,COMMASSIST,ROLL SHWR,\nNSMK,CONTINENTAL BREAKFAST"
}
},
"guests": {
"adults": 1
},
"price": {
"currency": "USD",
"base": "242.10",
"total": "281.31",
"variations": {
"average": {
"base": "242.10"
},
"changes": [
{
"startDate": "2020-09-13",
"endDate": "2020-09-14",
"base": "242.10"
}
]
}
},
"policies": {
"paymentType": "guarantee",
"cancellation": {
"deadline": "2020-09-11T09:30:00+05:30"
}
}
}
],
"self": "https://test.api.amadeus.com/v2/shopping/hotel-offers/by-hotel?hotelId=BWNYC133"
}
],
"meta": {
"links": {
"next": "https://test.api.amadeus.com/v2/shopping/hotel-offers?cityCode=NYC&page[offset]=BF2MJFOB9ASN_100"
}
}
}}
When i pass the above value to the angular controller its becomes empty ,My Angular code
.then(function successCallback(response) {
var hexa = response.data;
alert(hexa);
console.log(hexa);
}
When making an API call using the .NET library for invoices, the tracking categories on the invoice lines have OptionId as en empty GUID. See below.
I'm setting the UpdatedDateUTC and it returns one result.
.NET Code
var query = api.Invoices.Page(page);
page++;
if (lastUpdatedTime.HasValue)
{
query = query.ModifiedSince(lastUpdatedTime.Value.AsUtc());
}
invoices = query.OrderBy("UpdatedDateUTC").Find();
Tracking category Object in Visual Studio
{Xero.Api.Core.Model.ItemTrackingCategory}
Errors: null
Id: {11692cb7-597c-4064-a4ac-655c60cedd0f}
Name: "Sales Rep"
Option: "Rob"
OptionId: {00000000-0000-0000-0000-000000000000}
ValidationStatus: Ok
Warnings: null
When I use the API previewer at api.xero.com I get the following JSON which shows the correct ids. Is there an issue with the .NET library? I was version 2.2.1.6 and tried upgrading to the latest nuget package version 2.2.1.12 with the same issue.
This has been working previously but recently stopped working correctly.
Response from Xero API Previewer (api.xero.com)
{
"Id": "773e95c2-cec5-4f02-90c9-8c224b246e4f",
"Status": "OK",
"ProviderName": "Xero API Previewer",
"DateTimeUTC": "\/Date(1521545151271)\/",
"Invoices": [
{
"Type": "ACCREC",
"InvoiceID": "87fc8996-d881-47af-9c26-479705bbfb8a",
"InvoiceNumber": "INV-0088",
"Reference": "",
"Prepayments": [],
"Overpayments": [],
"CISDeduction": 0.00,
"AmountDue": 12000.00,
"AmountPaid": 0.00,
"SentToContact": false,
"CurrencyRate": 1.000000,
"HasErrors": false,
"IsDiscounted": false,
"HasAttachments": false,
"Attachments": [],
"Contact": {
"ContactID": "1bbc04e6-0c4a-4dca-9249-b9369759515b",
"ContactStatus": "ACTIVE",
"Name": "ELP Aviation",
"EmailAddress": "",
"BankAccountDetails": "",
"Addresses": [
{
"AddressType": "STREET",
"City": "",
"Region": "",
"PostalCode": "",
"Country": ""
},
{
"AddressType": "POBOX",
"City": "",
"Region": "",
"PostalCode": "",
"Country": ""
}
],
"Phones": [
{
"PhoneType": "DEFAULT",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "DDI",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "FAX",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
},
{
"PhoneType": "MOBILE",
"PhoneNumber": "",
"PhoneAreaCode": "",
"PhoneCountryCode": ""
}
],
"UpdatedDateUTC": "\/Date(1520356343967+0000)\/",
"ContactGroups": [],
"IsSupplier": false,
"IsCustomer": true,
"DefaultCurrency": "USD",
"SalesTrackingCategories": [],
"PurchasesTrackingCategories": [],
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2018-03-16T00:00:00",
"Date": "\/Date(1521158400000+0000)\/",
"DueDateString": "2018-03-17T00:00:00",
"DueDate": "\/Date(1521244800000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "1YR",
"Description": "SaaS 1 Year",
"UnitAmount": 12000.00,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 12000.00,
"AccountCode": "DEFREV",
"Tracking": [
{
"Name": "Revenue",
"Option": "New Business",
"TrackingCategoryID": "b054bce6-95e4-49b3-8d3f-6ed35554189c",
"TrackingOptionID": "509df853-d8d7-4450-b2d8-1d00fe9619a0"
},
{
"Name": "Sales Rep",
"Option": "Rob",
"TrackingCategoryID": "11692cb7-597c-4064-a4ac-655c60cedd0f",
"TrackingOptionID": "7a65b8c4-bba8-457c-9ddf-38d6442b2d49"
}
],
"Quantity": 1.0000,
"LineItemID": "c2b527cb-6677-4853-bb52-7263cba71ef9",
"ValidationErrors": []
}
],
"SubTotal": 12000.00,
"TotalTax": 0.00,
"Total": 12000.00,
"UpdatedDateUTC": "\/Date(1521230140920+0000)\/",
"CurrencyCode": "USD"
}
]
}
Raw response from Fiddler:
HTTP/1.1 200 OK
Cache-Control: private
Content-Type: application/json; charset=utf-8
Date: Mon, 19 Mar 2018 00:14:33 GMT
Strict-Transport-Security: max-age=31536000
WWW-Authenticate: OAuth Realm="api.xero.com"
Xero-Cell: egeby
Content-Length: 2187
Connection: keep-alive
{
"Id": "f9e4425a-a6fb-4682-b1b0-5ef1c9245727",
"Status": "OK",
"ProviderName": "AppNamePrivate (Demo)",
"DateTimeUTC": "\/Date(1521418474071)\/",
"Invoices": [
{
"Type": "ACCREC",
"InvoiceID": "87fc8996-d881-47af-9c26-479705bbfb8a",
"InvoiceNumber": "INV-0088",
"Reference": "",
"Payments": [],
"CreditNotes": [],
"Prepayments": [],
"Overpayments": [],
"AmountDue": 12000.00,
"AmountPaid": 0.00,
"AmountCredited": 0.00,
"CurrencyRate": 1.000000,
"HasErrors": false,
"IsDiscounted": false,
"HasAttachments": false,
"Contact": {
"ContactID": "1bbc04e6-0c4a-4dca-9249-b9369759515b",
"Name": "ELP Aviation",
"Addresses": [],
"Phones": [],
"ContactGroups": [],
"ContactPersons": [],
"HasValidationErrors": false
},
"DateString": "2018-03-16T00:00:00",
"Date": "\/Date(1521158400000+0000)\/",
"DueDateString": "2018-03-17T00:00:00",
"DueDate": "\/Date(1521244800000+0000)\/",
"Status": "AUTHORISED",
"LineAmountTypes": "Exclusive",
"LineItems": [
{
"ItemCode": "1YR",
"Description": "SaaS 1 Year",
"UnitAmount": 12000.0000,
"TaxType": "NONE",
"TaxAmount": 0.00,
"LineAmount": 12000.00,
"AccountCode": "DEFREV",
"Tracking": [
{
"Name": "Revenue",
"Option": "New Business",
"TrackingCategoryID": "b054bce6-95e4-49b3-8d3f-6ed35554189c",
"Options": []
},
{
"Name": "Sales Rep",
"Option": "Rob",
"TrackingCategoryID": "11692cb7-597c-4064-a4ac-655c60cedd0f",
"Options": []
}
],
"Quantity": 1.0000,
"LineItemID": "c2b527cb-6677-4853-bb52-7263cba71ef9"
}
],
"SubTotal": 12000.00,
"TotalTax": 0.00,
"Total": 12000.00,
"UpdatedDateUTC": "\/Date(1521230140920+0000)\/",
"CurrencyCode": "USD"
}
]
}
Missing information
As you can see the Fiddler response is missing the TackingOptionId that the API Previewer has. Invoice.LineItems[].Tracking[].TrackingOptionId
I have two json strings I want to compare.
The problem is that when the properties are the same but in a different order.
Simple example:
{
"Number": "123",
"Name": "My name",
"FirstName": "My First name",
"Prop1": false,
"Prop2": [],
"Plans": [],
"SomeList": [
{
"Code": "118",
"Period": {
"From": "2000-01-27T00:00:00.0000000",
"Until": "2003-12-31T00:00:00.0000000"
}
},
{
"Code": "120",
"Period": {
"From": "2004-01-01T00:00:00.0000000",
"Until": "2004-12-31T00:00:00.0000000"
}
}
]
}
and
{
"Number": "123",
"FirstName": "My First name",
"Name": "My name",
"Prop1": false,
"Prop2": [],
"Plans": [],
"SomeList": [
{
"Code": "120",
"Period": {
"From": "2004-01-01T00:00:00.0000000",
"Until": "2004-12-31T00:00:00.0000000"
}
},
{
"Code": "118",
"Period": {
"From": "2000-01-27T00:00:00.0000000",
"Until": "2003-12-31T00:00:00.0000000"
}
}
]
}
These two json's are equal.
The compare function JToken.DeepEquals says it's not equal.
And I don't want to serialize to an object XYZ to compare both jsons.
I want to sort the properties of the json so the JToken.DeepEquals works fine.
I use .Net Framework with WebApi on my Server and Javascript/AngularJs on my Client. I want to transfer an Tree with References to my Client. I found a Way to get it to the Client, i just set PreserveReferencesHandling.Objects at the Newtonsoft Json.
Json looks like this:
{
"$id": "1",
"id": 1,
"revisionNumber": 0,
"name": "Revision 0",
"parentRevisionNode": null,
"nextRevisionNode": null,
"prevRevisionNode": null,
"childRevisionNodes": [
{
"$id": "2",
"id": 2,
"revisionNumber": 0,
"name": "Node 1",
"parentRevisionNode": {
"$ref": "1"
},
"nextRevisionNode": null,
"prevRevisionNode": null,
"childRevisionNodes": [
{
"$id": "3",
"id": 3,
"revisionNumber": 0,
"name": "Node 1.1",
"parentRevisionNode": {
"$ref": "2"
},
"nextRevisionNode": null,
"prevRevisionNode": null,
"childRevisionNodes": null,
"data": {
"$id": "4",
"id": 3,
"revisionNumber": 0,
"text": "Data 1.1",
"parentRevisionNode": {
"$ref": "3"
},
"nextRevisionNode": null
}
},
{
"$id": "5",
"id": 4,
"revisionNumber": 0,
"name": "Node 1.2",
"parentRevisionNode": {
"$ref": "2"
},
"nextRevisionNode": null,
"prevRevisionNode": null,
"childRevisionNodes": null,
"data": {
"$id": "6",
"id": 4,
"revisionNumber": 0,
"text": "Data 1.2",
"parentRevisionNode": {
"$ref": "5"
},
"nextRevisionNode": null
}
}
],
"data": {
"$id": "7",
"id": 2,
"revisionNumber": 0,
"text": "Data 1",
"parentRevisionNode": {
"$ref": "2"
},
"nextRevisionNode": null
}
}
],
"data": {
"$id": "8",
"id": 1,
"revisionNumber": 0,
"text": "Data 0",
"parentRevisionNode": {
"$ref": "1"
},
"nextRevisionNode": null
}
}
I found a function that replaces the $id and $ref with the Object. Thats working fine.
Now i want the get that Object Tree back to the Server. But i get an error with circling references on JS Side. Then i thought i can do the same way back, transform the Object References with $id and $ref.
But Angulars $resource cuts out all the $ attributes...
Anyone a good Idea how to get Data back and forth from/to Server?
Thanks in advance
Greeetings
Ronny Gerndt