Retrieving data from JSON QPX

(YellowSum) #1

Hi Guy, I am new to JSON and trying to do a small project to call flight ticket price from QPX. I did the call successful from QPX with the following output


Status Code
200
Body
{
“kind”: “qpxExpress#tripsSearch”,
“trips”: {
“kind”: “qpxexpress#tripOptions”,
“requestId”: “Oqvv41ksE5zgGfev80R3uz”,
“data”: {
“kind”: “qpxexpress#data”,
“airport”: [
{
“kind”: “qpxexpress#airportData”,
“code”: “HAN”,
“city”: “HAN”,
“name”: “Hanoi Noi Bai International”
},
{
“kind”: “qpxexpress#airportData”,
“code”: “HKG”,
“city”: “HKG”,
“name”: “Hong Kong International”
},
{
“kind”: “qpxexpress#airportData”,
“code”: “REP”,
“city”: “REP”,
“name”: “Siem Reap Angkor International”
}
],
“city”: [
{
“kind”: “qpxexpress#cityData”,
“code”: “HAN”,
“name”: “Hanoi”
},
{
“kind”: “qpxexpress#cityData”,
“code”: “HKG”,
“name”: “Hong Kong”
},
{
“kind”: “qpxexpress#cityData”,
“code”: “REP”,
“name”: “Siem Reap”
}
],
“aircraft”: [
{
“kind”: “qpxexpress#aircraftData”,
“code”: “321”,
“name”: “Airbus A321”
}
],
“tax”: [
{
“kind”: “qpxexpress#taxData”,
“id”: “YQ_F”,
“name”: “VN YQ surcharge”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “I5_001”,
“name”: “Hong Kong Airport Passenger Security Charge”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “G3_001”,
“name”: “Hong Kong Airport Construction Fee”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “HK_001”,
“name”: “Hong Kong Air Passenger Departure Tax”
}
],
“carrier”: [
{
“kind”: “qpxexpress#carrierData”,
“code”: “VN”,
“name”: “Vietnam Airlines JSC”
}
]
},
“tripOption”: [
{
“kind”: “qpxexpress#tripOption”,
“saleTotal”: “HKD1701”,
“id”: “FjfEqOWKOv8TEQ0srp3CuK001”,
“slice”: [
{
“kind”: “qpxexpress#sliceInfo”,
“duration”: 320,
“segment”: [
{
“kind”: “qpxexpress#segmentInfo”,
“duration”: 125,
“flight”: {
“carrier”: “VN”,
“number”: “593”
},
“id”: “GWKeanNZTX+wsMfG”,
“cabin”: “COACH”,
“bookingCode”: “N”,
“bookingCodeCount”: 7,
“marriedSegmentGroup”: “0”,
“leg”: [
{
“kind”: “qpxexpress#legInfo”,
“id”: “LrQKTjrGlnu7ZSDP”,
“aircraft”: “321”,
“arrivalTime”: “2018-04-04T15:35+07:00”,
“departureTime”: “2018-04-04T14:30+08:00”,
“origin”: “HKG”,
“destination”: “HAN”,
“originTerminal”: “1”,
“destinationTerminal”: “2”,
“duration”: 125,
“mileage”: 525,
“meal”: “Refreshments”
}
],
“connectionDuration”: 95
},
{
“kind”: “qpxexpress#segmentInfo”,
“duration”: 100,
“flight”: {
“carrier”: “VN”,
“number”: “839”
},
“id”: “GhyBugHdatJ6DrUi”,
“cabin”: “COACH”,
“bookingCode”: “S”,
“bookingCodeCount”: 7,
“marriedSegmentGroup”: “1”,
“leg”: [
{
“kind”: “qpxexpress#legInfo”,
“id”: “LTOxvux14ommdq5Z”,
“aircraft”: “321”,
“arrivalTime”: “2018-04-04T18:50+07:00”,
“departureTime”: “2018-04-04T17:10+07:00”,
“origin”: “HAN”,
“destination”: “REP”,
“originTerminal”: “2”,
“destinationTerminal”: “I”,
“duration”: 100,
“mileage”: 555,
“meal”: “Snack or Brunch”
}
]
}
]
}
],
“pricing”: [
{
“kind”: “qpxexpress#pricingInfo”,
“fare”: [
{
“kind”: “qpxexpress#fareInfo”,
“id”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“carrier”: “VN”,
“origin”: “HKG”,
“destination”: “REP”,
“basisCode”: “NOXAN”
}
],
“segmentPricing”: [
{
“kind”: “qpxexpress#segmentPricing”,
“fareId”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“segmentId”: “GWKeanNZTX+wsMfG”
},
{
“kind”: “qpxexpress#segmentPricing”,
“fareId”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“segmentId”: “GhyBugHdatJ6DrUi”
}
],
“baseFareTotal”: “HKD1250”,
“saleFareTotal”: “HKD1250”,
“saleTaxTotal”: “HKD451”,
“saleTotal”: “HKD1701”,
“passengers”: {
“kind”: “qpxexpress#passengerCounts”,
“adultCount”: 1
},
“tax”: [
{
“kind”: “qpxexpress#taxInfo”,
“id”: “YQ_F”,
“chargeType”: “CARRIER_SURCHARGE”,
“code”: “YQ”,
“salePrice”: “HKD196”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “G3_001”,
“chargeType”: “GOVERNMENT”,
“code”: “G3”,
“country”: “HK”,
“salePrice”: “HKD90”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “HK_001”,
“chargeType”: “GOVERNMENT”,
“code”: “HK”,
“country”: “HK”,
“salePrice”: “HKD120”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “I5_001”,
“chargeType”: “GOVERNMENT”,
“code”: “I5”,
“country”: “HK”,
“salePrice”: “HKD45”
}
],
“fareCalculation”: “HKG VN X/HAN VN REP 160.36NOXAN NUC 160.36 END ROE 7.79469 FARE HKD 1250 XT 90G3 120HK 45I5 196YQ”,
“latestTicketingTime”: “2018-03-31T23:59-04:00”,
“ptc”: “ADT”,
“refundable”: true
}
]
}
]
}
}
Data
{
“kind”: “qpxExpress#tripsSearch”,
“trips”: {
“kind”: “qpxexpress#tripOptions”,
“requestId”: “Oqvv41ksE5zgGfev80R3uz”,
“data”: {
“kind”: “qpxexpress#data”,
“airport”: [
{
“kind”: “qpxexpress#airportData”,
“code”: “HAN”,
“city”: “HAN”,
“name”: “Hanoi Noi Bai International”
},
{
“kind”: “qpxexpress#airportData”,
“code”: “HKG”,
“city”: “HKG”,
“name”: “Hong Kong International”
},
{
“kind”: “qpxexpress#airportData”,
“code”: “REP”,
“city”: “REP”,
“name”: “Siem Reap Angkor International”
}
],
“city”: [
{
“kind”: “qpxexpress#cityData”,
“code”: “HAN”,
“name”: “Hanoi”
},
{
“kind”: “qpxexpress#cityData”,
“code”: “HKG”,
“name”: “Hong Kong”
},
{
“kind”: “qpxexpress#cityData”,
“code”: “REP”,
“name”: “Siem Reap”
}
],
“aircraft”: [
{
“kind”: “qpxexpress#aircraftData”,
“code”: “321”,
“name”: “Airbus A321”
}
],
“tax”: [
{
“kind”: “qpxexpress#taxData”,
“id”: “YQ_F”,
“name”: “VN YQ surcharge”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “I5_001”,
“name”: “Hong Kong Airport Passenger Security Charge”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “G3_001”,
“name”: “Hong Kong Airport Construction Fee”
},
{
“kind”: “qpxexpress#taxData”,
“id”: “HK_001”,
“name”: “Hong Kong Air Passenger Departure Tax”
}
],
“carrier”: [
{
“kind”: “qpxexpress#carrierData”,
“code”: “VN”,
“name”: “Vietnam Airlines JSC”
}
]
},
“tripOption”: [
{
“kind”: “qpxexpress#tripOption”,
“saleTotal”: “HKD1701”,
“id”: “FjfEqOWKOv8TEQ0srp3CuK001”,
“slice”: [
{
“kind”: “qpxexpress#sliceInfo”,
“duration”: 320,
“segment”: [
{
“kind”: “qpxexpress#segmentInfo”,
“duration”: 125,
“flight”: {
“carrier”: “VN”,
“number”: “593”
},
“id”: “GWKeanNZTX+wsMfG”,
“cabin”: “COACH”,
“bookingCode”: “N”,
“bookingCodeCount”: 7,
“marriedSegmentGroup”: “0”,
“leg”: [
{
“kind”: “qpxexpress#legInfo”,
“id”: “LrQKTjrGlnu7ZSDP”,
“aircraft”: “321”,
“arrivalTime”: “2018-04-04T15:35+07:00”,
“departureTime”: “2018-04-04T14:30+08:00”,
“origin”: “HKG”,
“destination”: “HAN”,
“originTerminal”: “1”,
“destinationTerminal”: “2”,
“duration”: 125,
“mileage”: 525,
“meal”: “Refreshments”
}
],
“connectionDuration”: 95
},
{
“kind”: “qpxexpress#segmentInfo”,
“duration”: 100,
“flight”: {
“carrier”: “VN”,
“number”: “839”
},
“id”: “GhyBugHdatJ6DrUi”,
“cabin”: “COACH”,
“bookingCode”: “S”,
“bookingCodeCount”: 7,
“marriedSegmentGroup”: “1”,
“leg”: [
{
“kind”: “qpxexpress#legInfo”,
“id”: “LTOxvux14ommdq5Z”,
“aircraft”: “321”,
“arrivalTime”: “2018-04-04T18:50+07:00”,
“departureTime”: “2018-04-04T17:10+07:00”,
“origin”: “HAN”,
“destination”: “REP”,
“originTerminal”: “2”,
“destinationTerminal”: “I”,
“duration”: 100,
“mileage”: 555,
“meal”: “Snack or Brunch”
}
]
}
]
}
],
“pricing”: [
{
“kind”: “qpxexpress#pricingInfo”,
“fare”: [
{
“kind”: “qpxexpress#fareInfo”,
“id”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“carrier”: “VN”,
“origin”: “HKG”,
“destination”: “REP”,
“basisCode”: “NOXAN”
}
],
“segmentPricing”: [
{
“kind”: “qpxexpress#segmentPricing”,
“fareId”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“segmentId”: “GWKeanNZTX+wsMfG”
},
{
“kind”: “qpxexpress#segmentPricing”,
“fareId”: “A+18Toty6MCiRPAhNaC9a2+UNkk1qal1HBH6jAU6Iilk”,
“segmentId”: “GhyBugHdatJ6DrUi”
}
],
“baseFareTotal”: “HKD1250”,
“saleFareTotal”: “HKD1250”,
“saleTaxTotal”: “HKD451”,
“saleTotal”: “HKD1701”,
“passengers”: {
“kind”: “qpxexpress#passengerCounts”,
“adultCount”: 1
},
“tax”: [
{
“kind”: “qpxexpress#taxInfo”,
“id”: “YQ_F”,
“chargeType”: “CARRIER_SURCHARGE”,
“code”: “YQ”,
“salePrice”: “HKD196”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “G3_001”,
“chargeType”: “GOVERNMENT”,
“code”: “G3”,
“country”: “HK”,
“salePrice”: “HKD90”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “HK_001”,
“chargeType”: “GOVERNMENT”,
“code”: “HK”,
“country”: “HK”,
“salePrice”: “HKD120”
},
{
“kind”: “qpxexpress#taxInfo”,
“id”: “I5_001”,
“chargeType”: “GOVERNMENT”,
“code”: “I5”,
“country”: “HK”,
“salePrice”: “HKD45”
}
],
“fareCalculation”: “HKG VN X/HAN VN REP 160.36NOXAN NUC 160.36 END ROE 7.79469 FARE HKD 1250 XT 90G3 120HK 45I5 196YQ”,
“latestTicketingTime”: “2018-03-31T23:59-04:00”,
“ptc”: “ADT”,
“refundable”: true
}
]
}
]
}
}

When I try to retrieve the saleTotal from the response by :
{“saleTotal”: “{{qpx.data__trips__tripOption__saleTotal}}”}

It failed with status code 422. I tried different code for the JSON. but cannot work it out yet.
anyone know where did I go wrong ?

(Daniel Beckett) #2

@YellowSum

Would you be able to share your flow with the support team so that we can take a look? Should be able to offer more advice if we can see it in action :slight_smile:

You can get the share link by clicking on the ‘Private’ button in your flow editor - once you have this please email it to support@flowxo.com

Thanks,
Dan

(YellowSum) #3

HI dan

thank for your mail, here it is

https://flowxo.com/share/xw84yxk6

I was trying to call from google QPX and send it back to my bot.

but I cannot call the data out on flowxo side.

let me know. thanks

(Sarah Palombo) #4

Hey there :wave:!

For Sale Total, you’ll need to use {{qpx.data__trips__tripOption__0__saleTotal}} here

Hope that helps ! :slight_smile:

Sarah.

1 Like