This question already has answers here:
Passing bash variable to jq
(10 answers)
Closed 12 months ago.
i have a json file containing data about Jenkins stages.
assuming i have the stage name stored in a variable how do i retrieve the "durationMillis" value from that stage
STAGE1="CLEANUP WORKSTATION"
so far i was able to dissect the last job (json containing 3 last Jenkins jobs)
cat file.json | jq '.[] | select(.id=='\"$BUILD_NUMBER\"')'
outcome should present "157"
[
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/wfapi/describe"
}
},
"id": "72",
"name": "#72",
"status": "SUCCESS",
"startTimeMillis": 1646952992850,
"endTimeMillis": 1646953018448,
"durationMillis": 25598,
"queueDurationMillis": 24,
"pauseDurationMillis": 0,
"stages": [
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/8/wfapi/describe"
}
},
"id": "8",
"name": "CLEANUP WORKSTATION",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953001559,
"durationMillis": 157,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/12/wfapi/describe"
}
},
"id": "12",
"name": "GIT CLONE",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953001716,
"durationMillis": 302,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/25/wfapi/describe"
}
},
"id": "25",
"name": "ALL STAGES",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953002199,
"durationMillis": 893,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/33/wfapi/describe"
}
},
"id": "33",
"name": "STAGE1",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953003092,
"durationMillis": 3760,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/35/wfapi/describe"
}
},
"id": "35",
"name": "STAGE2",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953003196,
"durationMillis": 7348,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/37/wfapi/describe"
}
},
"id": "37",
"name": "STAGE3",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953003241,
"durationMillis": 5522,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/72/execution/node/90/wfapi/describe"
}
},
"id": "90",
"name": "Declarative: Post Actions",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646953010757,
"durationMillis": 7430,
"pauseDurationMillis": 0
}
]
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/wfapi/describe"
}
},
"id": "71",
"name": "#71",
"status": "SUCCESS",
"startTimeMillis": 1646952745744,
"endTimeMillis": 1646952770031,
"durationMillis": 24287,
"queueDurationMillis": 19,
"pauseDurationMillis": 0,
"stages": [
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/8/wfapi/describe"
}
},
"id": "8",
"name": "CLEANUP WORKSTATION",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952754330,
"durationMillis": 203,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/12/wfapi/describe"
}
},
"id": "12",
"name": "GIT CLONE",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952754533,
"durationMillis": 457,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/25/wfapi/describe"
}
},
"id": "25",
"name": "ALL STAGES",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952756222,
"durationMillis": 536,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/33/wfapi/describe"
}
},
"id": "33",
"name": "STAGE1",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952756758,
"durationMillis": 4344,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/35/wfapi/describe"
}
},
"id": "35",
"name": "STAGE2",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952756811,
"durationMillis": 6175,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/37/wfapi/describe"
}
},
"id": "37",
"name": "STAGE3",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952756842,
"durationMillis": 4167,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/71/execution/node/90/wfapi/describe"
}
},
"id": "90",
"name": "Declarative: Post Actions",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952763230,
"durationMillis": 6588,
"pauseDurationMillis": 0
}
]
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/wfapi/describe"
}
},
"id": "70",
"name": "#70",
"status": "FAILED",
"startTimeMillis": 1646952648485,
"endTimeMillis": 1646952669992,
"durationMillis": 21507,
"queueDurationMillis": 16,
"pauseDurationMillis": 0,
"stages": [
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/8/wfapi/describe"
}
},
"id": "8",
"name": "CLEANUP WORKSTATION",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952657661,
"durationMillis": 177,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/12/wfapi/describe"
}
},
"id": "12",
"name": "GIT CLONE",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952657838,
"durationMillis": 349,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/25/wfapi/describe"
}
},
"id": "25",
"name": "ALL STAGES",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952658407,
"durationMillis": 198,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/33/wfapi/describe"
}
},
"id": "33",
"name": "STAGE1",
"execNode": "",
"status": "FAILED",
"error": {
"message": "script returned exit code 2",
"type": "hudson.AbortException"
},
"startTimeMillis": 1646952658605,
"durationMillis": 3434,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/35/wfapi/describe"
}
},
"id": "35",
"name": "STAGE2",
"execNode": "",
"status": "FAILED",
"error": {
"message": "script returned exit code 2",
"type": "hudson.AbortException"
},
"startTimeMillis": 1646952658638,
"durationMillis": 5948,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/37/wfapi/describe"
}
},
"id": "37",
"name": "STAGE3",
"execNode": "",
"status": "FAILED",
"error": {
"message": "script returned exit code 2",
"type": "hudson.AbortException"
},
"startTimeMillis": 1646952658669,
"durationMillis": 3969,
"pauseDurationMillis": 0
},
{
"_links": {
"self": {
"href": "/jenkins/cag-sw-jenkins/job/test/job/test-hagay-elk-kv/70/execution/node/90/wfapi/describe"
}
},
"id": "90",
"name": "Declarative: Post Actions",
"execNode": "",
"status": "SUCCESS",
"startTimeMillis": 1646952664887,
"durationMillis": 4873,
"pauseDurationMillis": 0
}
]
}
]
i worked it a bit and was able to extract what i needed
export BUILD_NUMBER='72'
export STAGE1="CLEANUP WORKSTATION"
cat file.json | jq '.[] | select(.id==env.BUILD_NUMBER) | .stages | .[] | select(.name | contains(env.STAGE1)) | .durationMillis'
Related
I am trying to search for flights between two places in Sabre using BargainFindermax API. The API provides me with a list of all flights. However, there is no direct relation to which of the flights are linked.
For example, I searched for flights between BLR > LCY. The response I got included flights for AMS > LCY, BLR > DEL, BLR > DEL, DEL > AMS, AMS > LCY.
From this, I can construct the following route BLR > DEL > AMS > LCY. But there are two flights for BLR > DEL and AMS > LCY.
How can I identify which of these flights are related?
Here is the complete JSON response,
{
"groupedItineraryResponse": {
"version": "5.2.0",
"messages": [
{
"severity": "Info",
"type": "WORKERTHREAD",
"code": "TRANSACTIONID",
"text": "2074398531853061390"
},
{
"severity": "Info",
"type": "SERVER",
"code": "ASE032LPSCIL9UM.IDM.SGDCCERT.SABRE.COM",
"text": "27036"
},
{
"severity": "Info",
"type": "DRE",
"code": "RULEID",
"text": "17203"
},
{
"severity": "Info",
"type": "DEFAULT",
"code": "RULEID",
"text": "25238"
}
],
"statistics": {
"itineraryCount": 2
},
"scheduleDescs": [
{
"id": 1,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "08:45:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "08:50:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 985,
"operating": "KL",
"operatingFlightNumber": 985,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 2,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "19:50:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:50:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3798,
"operating": "9W",
"operatingFlightNumber": 812,
"disclosure": "9W",
"equipment": {
"code": "73H",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 3,
"trafficRestriction": "G",
"frequency": "SMTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 1058,
"departure": {
"airport": "BLR",
"city": "BLR",
"country": "IN",
"time": "18:55:00+05:30"
},
"arrival": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "22:00:00+05:30",
"terminal": "3"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3703,
"operating": "9W",
"operatingFlightNumber": 833,
"disclosure": "9W",
"equipment": {
"code": "738",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
},
{
"id": 4,
"frequency": "*M**T**",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 3961,
"departure": {
"airport": "DEL",
"city": "DEL",
"country": "IN",
"time": "02:10:00+05:30",
"terminal": "3"
},
"arrival": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "07:40:00+02:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 3817,
"operating": "9W",
"operatingFlightNumber": 234,
"disclosure": "9W",
"equipment": {
"code": "333",
"typeForFirstLeg": "W",
"typeForLastLeg": "W"
}
}
},
{
"id": 5,
"frequency": "*MTWTFS",
"stopCount": 0,
"eTicketable": true,
"totalMilesFlown": 257,
"departure": {
"airport": "AMS",
"city": "AMS",
"country": "NL",
"time": "09:25:00+02:00"
},
"arrival": {
"airport": "LCY",
"city": "LON",
"country": "GB",
"time": "09:30:00+01:00"
},
"carrier": {
"marketing": "KL",
"marketingFlightNumber": 987,
"operating": "KL",
"operatingFlightNumber": 987,
"codeShared": "/KLM CITYHOPPER",
"equipment": {
"code": "E90",
"typeForFirstLeg": "N",
"typeForLastLeg": "N"
}
}
}
],
"taxDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 799,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"taxSummaryDescs": [
{
"id": 1,
"code": "YRI",
"amount": 160,
"currency": "USD",
"description": "SERVICE FEE - CARRIER-IMPOSED MISC",
"publishedAmount": 160,
"publishedCurrency": "USD",
"station": "DEL"
},
{
"id": 2,
"code": "YQI",
"amount": 13.3,
"currency": "USD",
"description": "SERVICE FEE - INSURANCE",
"publishedAmount": 925,
"publishedCurrency": "INR",
"station": "BLR"
},
{
"id": 3,
"code": "WO",
"amount": 3.8,
"currency": "USD",
"description": "PASSENGER SERVICE FEE",
"publishedAmount": 3.8,
"publishedCurrency": "USD",
"station": "BLR",
"country": "IN"
},
{
"id": 4,
"code": "K38",
"amount": 11.5,
"currency": "USD",
"description": "GOODS AND SERVICE TAX INTERIM DOMESTIC AND INTERNATIONAL",
"publishedAmount": 0.05,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
},
{
"id": 5,
"code": "CJ",
"amount": 7.4,
"currency": "USD",
"description": "SECURITY SERVICE CHARGE",
"publishedAmount": 6.5,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 6,
"code": "RN",
"amount": 7.3,
"currency": "USD",
"description": "PASSENGER SERVICE CHARGE",
"publishedAmount": 6.4,
"publishedCurrency": "EUR",
"station": "AMS",
"country": "NL"
},
{
"id": 7,
"code": "IN",
"amount": 5.2,
"currency": "USD",
"description": "USER DEVELOPMENT FEE DEPARTURES",
"publishedAmount": 362,
"publishedCurrency": "INR",
"station": "BLR",
"country": "IN"
}
],
"fareComponentDescs": [
{
"id": 1,
"governingCarrier": "KL",
"fareAmount": 24.65,
"fareCurrency": "INR",
"fareBasisCode": "XPLWIA",
"farePassengerType": "ADT",
"publishedFareAmount": 1717,
"oneWayFare": true,
"directionality": "FROM",
"direction": "EH",
"notValidBefore": "2019-07-21",
"notValidAfter": "2019-07-21",
"applicablePricingCategories": "4 5 6 7 8 10 12 16 18",
"vendorCode": "ATP",
"fareTypeBitmap": "00",
"fareType": "PRU",
"fareTariff": "4",
"fareRule": "INPL",
"segments": [
{
"segment": {
"surcharges": [
{
"amount": 28.71,
"currency": "NUC",
"description": "MISCELLANEOUS/OTHER",
"type": "Q"
}
]
}
},
{
"segment": {}
},
{
"segment": {}
}
]
}
],
"validatingCarrierDescs": [
{
"id": 1,
"settlementMethod": "ARC",
"newVcxProcess": true,
"default": {
"code": "DL"
}
}
],
"baggageAllowanceDescs": [
{
"id": 1,
"pieceCount": 1
}
],
"legDescs": [
{
"id": 1,
"schedules": [
{
"ref": 2
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 5,
"departureDateAdjustment": 1
}
]
},
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"ref": 4,
"departureDateAdjustment": 1
},
{
"ref": 1,
"departureDateAdjustment": 1
}
]
}
],
"itineraryGroups": [
{
"groupDescription": {
"legDescriptions": [
{
"departureDate": "2019-07-21",
"departureLocation": "BLR",
"arrivalLocation": "LCY"
}
]
},
"itineraries": [
{
"id": 1,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 2
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 409.855
}
},
{
"id": 2,
"pricingSource": "ADVJR1",
"legs": [
{
"ref": 1
}
],
"pricingInformation": [
{
"pricingSubsource": "MIP",
"fare": {
"validatingCarrierCode": "DL",
"vita": true,
"eTicketable": true,
"lastTicketDate": "2019-07-05",
"governingCarriers": "KL",
"passengerInfoList": [
{
"passengerInfo": {
"passengerType": "ADT",
"passengerNumber": 1,
"nonRefundable": true,
"fareComponents": [
{
"ref": 1,
"segments": [
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "D",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "X",
"cabinCode": "Y",
"mealCode": "RB",
"seatsAvailable": 9
}
},
{
"segment": {
"bookingCode": "L",
"cabinCode": "Y",
"mealCode": "M",
"seatsAvailable": 9,
"availabilityBreak": true
}
}
]
}
],
"taxes": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 7
},
{
"ref": 4
},
{
"ref": 3
},
{
"ref": 5
},
{
"ref": 6
}
],
"taxSummaries": [
{
"ref": 2
},
{
"ref": 1
},
{
"ref": 3
},
{
"ref": 4
},
{
"ref": 7
},
{
"ref": 5
},
{
"ref": 6
}
],
"currencyConversion": {
"from": "INR",
"to": "USD",
"exchangeRateUsed": 0.01442679
},
"fareMessages": [
{
"type": "N",
"code": "0",
"carrier": "KL",
"info": "FARE RESTRICTIONS APPLY/CARRIER RESTRICTIONS APPLY"
},
{
"type": "W",
"code": "0",
"info": "VALIDATING CARRIER - DL PER GSA AGREEMENT WITH KL"
}
],
"passengerTotalFare": {
"totalFare": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"equivalentAmount": 56,
"equivalentCurrency": "USD",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"commissionPercentage": 0,
"commissionAmount": 0,
"exchangeRateOne": 69.651352
},
"baggageInformation": [
{
"provisionType": "A",
"airlineCode": "KL",
"segments": [
{
"id": 0
},
{
"id": 1
},
{
"id": 2
}
],
"allowance": {
"ref": 1
}
}
]
}
}
],
"totalFare": {
"totalPrice": 264.5,
"totalTaxAmount": 208.5,
"currency": "USD",
"baseFareAmount": 3875,
"baseFareCurrency": "INR",
"constructionAmount": 55.59,
"constructionCurrency": "NUC",
"equivalentAmount": 56,
"equivalentCurrency": "USD"
},
"validatingCarriers": [
{
"ref": 1
}
]
}
}
],
"diversitySwapper": {
"weighedPrice": 367.631
}
}
]
}
]
}
}
You have to use legDescs list to connect your segments, and use those "ref" values.
For example:
{
"id": 2,
"schedules": [
{
"ref": 3
},
{
"departureDateAdjustment": 1,
"ref": 4
},
{
"departureDateAdjustment": 1,
"ref": 1
}
]
}
means, your flight with ID = 2 contains 3 segments, with id 3 - 4 and 1. When you search numbered segments in "scheduleDescs" object, you can see routes are:
BLR - DEL
DEL - AMS
AMS - LCY
and as you can see you got the BLR - LCY flight.
I want to get an image URL from WP REST API, I was retrieving my posts to a List
so getting featuredImageUrl was like this :
A)
//THIS GETS AN URL TO ATTACHMENT WHEN IM USING A LIST<DYNAMIC>
featuredMediaAtta = posts[index]["_embedded"]["wp:featuredmedia"][0]["source_url"],
result is a url of embedded attachment, I want the same results in B
B)
I had to changed to Object Model from list to List>
The post model is:
Post.fromMap(Map<String, dynamic> map) {
if (map == null) {
return;
}
...
//I can retrieve featured media id successfully
featuredMediaID = map['featured_media'];
// BUT HERE I CAN NOT RETURN THE ATTACHMENT URL
featuredMediaAtta = map["_embedded"]["wp:featuredmedia"][0]["source_url"] ;
commentStatus = map['comment_status'];
...
here is the JSON response for getting
http://www.ehawal.com/wp-json/wp/v2/posts/73335?_embed
{
"id": 73335,
"date": "2018-12-01T20:05:26",
"date_gmt": "2018-12-01T20:05:26",
"guid": {
"rendered": "http://www.theUrl.com/?p=73335"
},
"modified": "2018-12-01T20:05:26",
"modified_gmt": "2018-12-01T20:05:26",
"slug": "%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e",
"status": "publish",
"type": "post",
"link": "http://www.theUrl.com/2018/12/01/%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e/",
"title": {
"rendered": "بو وێنه\u200cی نوێ"
},
"content": {
"rendered": "<p>وێمه\u200cی لكسادژڤ ؛لكژ اعس</p>\n<div class=\"theUrl_container\"
"protected": false
},
"excerpt": {
"rendered": "<p>وێمه\u200cی لكسادژڤ ؛لكژ اعس</p>\n<div class=\"theUrl_container\" style=\"\"><!-- theUrl.com BEGIN --><span class=\"theUrl-wrapper\"
"author": 1,
"featured_media": 73336,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
195,
1,
176
],
"tags": [],
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"replies": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/comments?post=73335"
}
],
"version-history": [
{
"count": 1,
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335/revisions"
}
],
"predecessor-version": [
{
"id": 73337,
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335/revisions/73337"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/media/73336"
}
],
"wp:attachment": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/media?parent=73335"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/categories?post=73335"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/tags?post=73335"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
},
"_embedded": {
"author": [
{
"id": 1,
"name": "hooshyar_nuc",
"url": "",
"description": "",
"link": "http://www.theUrl.com/author/hooshyar_nuc/",
"slug": "hooshyar_nuc",
"avatar_urls": {
"24": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=24&d=mm&r=g",
"48": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=48&d=mm&r=g",
"96": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=96&d=mm&r=g"
},
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/users"
}
]
}
}
],
"wp:featuredmedia": [
{
"id": 73336,
"date": "2018-12-01T20:05:10",
"slug": "guardian",
"type": "attachment",
"link": "http://www.theUrl.com/2018/12/01/%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e/guardian/",
"title": {
"rendered": "guardian"
},
"author": 1,
"acf": [],
"caption": {
"rendered": ""
},
"alt_text": "",
"media_type": "image",
"mime_type": "image/png",
"media_details": {
"width": 400,
"height": 155,
"file": "2018/12/guardian.png",
"sizes": {
"thumbnail": {
"file": "guardian-150x150.png",
"width": 150,
"height": 150,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-150x150.png"
},
"medium": {
"file": "guardian-300x116.png",
"width": 300,
"height": 116,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-300x116.png"
},
"tie-small": {
"file": "guardian-110x75.png",
"width": 110,
"height": 75,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-110x75.png"
},
"tie-medium": {
"file": "guardian-310x155.png",
"width": 310,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-310x155.png"
},
"tie-large": {
"file": "guardian-310x155.png",
"width": 310,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-310x155.png"
},
"full": {
"file": "guardian.png",
"width": 400,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian.png"
}
},
"image_meta": {
"aperture": "0",
"credit": "",
"camera": "",
"caption": "",
"created_timestamp": "0",
"copyright": "",
"focal_length": "0",
"iso": "0",
"shutter_speed": "0",
"title": "",
"orientation": "0",
"keywords": []
}
},
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian.png",
"_links": {
"self": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/media/73336"
}
],
"collection": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/media"
}
],
"about": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/types/attachment"
}
],
"author": [
{
"attributes": {
"embeddable": true
},
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"replies": [
{
"attributes": {
"embeddable": true
},
"href": "http://www.theUrl.com/wp-json/wp/v2/comments?post=73336"
}
]
}
}
],
"wp:term": [
[
{
"id": 195,
"link": "http://www.theUrl.com/category/world/",
"name": "جیهان",
"slug": "world",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/195"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=195"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 1,
"link": "http://www.theUrl.com/category/all/",
"name": "سه\u200cره\u200cكی",
"slug": "all",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/1"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=1"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 176,
"link": "http://www.theUrl.com/category/grng/",
"name": "گرنگ",
"slug": "grng",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/176"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=176"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
],
[]
]
}
}
I'm working with the confluence API and testing some endpoints in the browser to make sure it returns the right information and then fetching with curl.
When I go to the following url:
http://localhost:8090/rest/api/content/search?cql=label+%3D+%22program-status-rollup-employee%22&expand=space
I get the following JSON:
{
"results": [
{
"id": "2064397",
"type": "page",
"status": "current",
"title": "TL Employee Reports",
"space": {
"id": 98306,
"key": "COM",
"name": "Compass",
"type": "global",
"_expandable": {
"metadata": "",
"icon": "",
"description": "",
"homepage": "/rest/api/content/65584"
},
"_links": {
"self": "http://localhost:8090/rest/api/space/COM",
"webui": "/display/COM"
}
},
"extensions": {
"position": "none"
},
"_expandable": {
"container": "/rest/api/space/COM",
"metadata": "",
"operations": "",
"children": "/rest/api/content/2064397/child",
"restrictions": "/rest/api/content/2064397/restriction/byOperation",
"history": "/rest/api/content/2064397/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/2064397/descendant"
},
"_links": {
"self": "http://localhost:8090/rest/api/content/2064397",
"webui": "/display/COM/TL+Employee+Reports",
"edit": "/pages/resumedraft.action?draftId=2064397&draftShareId=0906da34-3930-4c15-8339-d85c309f6cc0",
"tinyui": "/x/DYAf"
}
},
{
"id": "2064402",
"type": "page",
"status": "current",
"title": "Employee Reports",
"space": {
"id": 2162689,
"key": "NC",
"name": "New Compass",
"type": "global",
"_expandable": {
"metadata": "",
"icon": "",
"description": "",
"homepage": "/rest/api/content/2064389"
},
"_links": {
"self": "http://localhost:8090/rest/api/space/NC",
"webui": "/display/NC"
}
},
"extensions": {
"position": "none"
},
"_expandable": {
"container": "/rest/api/space/NC",
"metadata": "",
"operations": "",
"children": "/rest/api/content/2064402/child",
"restrictions": "/rest/api/content/2064402/restriction/byOperation",
"history": "/rest/api/content/2064402/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/2064402/descendant"
},
"_links": {
"self": "http://localhost:8090/rest/api/content/2064402",
"webui": "/display/NC/Employee+Reports",
"edit": "/pages/resumedraft.action?draftId=2064402&draftShareId=8fb3e862-e52f-498d-83d5-6b6046682070",
"tinyui": "/x/EoAf"
}
},
{
"id": "819224",
"type": "page",
"status": "current",
"title": "Employee Reports",
"space": {
"id": 98306,
"key": "COM",
"name": "Compass",
"type": "global",
"_expandable": {
"metadata": "",
"icon": "",
"description": "",
"homepage": "/rest/api/content/65584"
},
"_links": {
"self": "http://localhost:8090/rest/api/space/COM",
"webui": "/display/COM"
}
},
"extensions": {
"position": "none"
},
"_expandable": {
"container": "/rest/api/space/COM",
"metadata": "",
"operations": "",
"children": "/rest/api/content/819224/child",
"restrictions": "/rest/api/content/819224/restriction/byOperation",
"history": "/rest/api/content/819224/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/819224/descendant"
},
"_links": {
"self": "http://localhost:8090/rest/api/content/819224",
"webui": "/display/COM/Employee+Reports",
"edit": "/pages/resumedraft.action?draftId=819224&draftShareId=0df4eb62-9bb6-4532-a445-4002695dcb90",
"tinyui": "/x/GIAM"
}
}
],
"start": 0,
"limit": 25,
"size": 3,
"_links": {
"base": "http://localhost:8090",
"context": "",
"self": "http://localhost:8090/rest/api/content/search?expand=space&cql=label+%3D+%22program-status-rollup-employee%22"
}
}
But when I get the same endpoint via curl:
curl -u $user:$password http://localhost:8090/rest/api/content/search?cql=label+%3D+%22program-status-rollup-employee%22&expand=space
I don't get all of the information:
{
"results":[
{
"id":"2064397",
"type":"page",
"status":"current",
"title":"TL Employee Reports",
"restrictions":{
},
"_expandable":{
"container":"",
"metadata":"",
"extensions":"",
"operations":"",
"children":"",
"history":"/rest/api/content/2064397/history",
"ancestors":"",
"body":"",
"version":"",
"descendants":"",
"space":"/rest/api/space/COM"
},
"_links":{
"self":"http://localhost:8090/rest/api/content/2064397",
"webui":"/display/COM/TL+Employee+Reports",
"tinyui":"/x/DYAf"
}
},
{
"id":"2064402",
"type":"page",
"status":"current",
"title":"Employee Reports",
"restrictions":{
},
"_expandable":{
"container":"",
"metadata":"",
"extensions":"",
"operations":"",
"children":"",
"history":"/rest/api/content/2064402/history",
"ancestors":"",
"body":"",
"version":"",
"descendants":"",
"space":"/rest/api/space/NC"
},
"_links":{
"self":"http://localhost:8090/rest/api/content/2064402",
"webui":"/display/NC/Employee+Reports",
"tinyui":"/x/EoAf"
}
},
{
"id":"819224",
"type":"page",
"status":"current",
"title":"Employee Reports",
"restrictions":{
},
"_expandable":{
"container":"",
"metadata":"",
"extensions":"",
"operations":"",
"children":"",
"history":"/rest/api/content/819224/history",
"ancestors":"",
"body":"",
"version":"",
"descendants":"",
"space":"/rest/api/space/COM"
},
"_links":{
"self":"http://localhost:8090/rest/api/content/819224",
"webui":"/display/COM/Employee+Reports",
"tinyui":"/x/GIAM"
}
}
],
"start":0,
"limit":25,
"size":3,
"_links":{
"base":"http://localhost:8090",
"context":"",
"self":"http://localhost:8090/rest/api/content/search?cql=label+%3D+%22program-status-rollup-employee%22"
}
}
Specifically it omits the space object, which I need. Any thoughts?
I needed to escape the ampersand with single quotes. Once I did that, it returned the json that I saw in the browser
http://localhost:8090/rest/api/content/search?cql=label+%3D+%22program-status-rollup-employee%22'&'expand=space
I am trying to get json converted from:
{
"Devices": [
{
"Udid": "7a2b0e6c928f2321a75e423ba23ae93d",
"SerialNumber": "RF1D232ZLEE",
"MacAddress": "40F232726FC8",
"Imei": "3576342323280150",
"EasId": "SEC1BC252327E92B",
"AssetNumber": "7a2b0e23223928f2321a75e423ba23ae93d",
"DeviceFriendlyName": "gel1 Android Android 5.0.1 ZLEE ",
"LocationGroupId": {
"Id": {
"Value": 19529
},
"Name": "Group Express"
},
"LocationGroupName": "Group Express",
"UserId": {
"Name": ""
},
"UserName": "",
"UserEmailAddress": "",
"Ownership": "S",
"PlatformId": {
"Id": {
"Value": 5
},
"Name": "Android"
},
"Platform": "Android",
"ModelId": {
"Id": {
"Value": 5
},
"Name": "samsung GT-I9505"
},
"Model": "samsung GT-I9505",
"OperatingSystem": "5.0.1",
"PhoneNumber": "+447881867010",
"LastSeen": "2016-07-06T14:01:03.590",
"EnrollmentStatus": "Unenrolled",
"ComplianceStatus": "NotAvailable",
"CompromisedStatus": false,
"LastEnrolledOn": "2016-06-15T16:01:38.763",
"LastComplianceCheckOn": "0001-01-01T00:00:00.000",
"LastCompromisedCheckOn": "2016-07-06T13:58:26.183",
"IsSupervised": false,
"DeviceMCC": {
"SIMMCC": "234",
"CurrentMCC": "234"
},
"AcLineStatus": 0,
"VirtualMemory": 0,
"Id": {
"Value": 23459
}
},
{
"Udid": "c5f94db71d406dae7f881d3edf059e",
"SerialNumber": "",
"MacAddress": "000C300F9108",
"Imei": "",
"EasId": "D80DB85EC411C8E9B28BC292A603F05C2C0EEEC8",
"AssetNumber": "c592f93db71d406dae7f881d3edf059e",
"DeviceFriendlyName": "user Windows 10 WinRT 10.0.10240 ",
"LocationGroupId": {
"Id": {
"Value": 18498
},
"Name": "Business Solutions"
},
"LocationGroupName": "Business Solutions",
"UserId": {
"Name": ""
},
"UserName": "",
"UserEmailAddress": "",
"Ownership": "C",
"PlatformId": {
"Id": {
"Value": 12
},
"Name": "WinRT"
},
"Platform": "WinRT",
"ModelId": {
"Id": {
"Value": 50
},
"Name": "Windows 10"
},
"Model": "Windows 10",
"OperatingSystem": "10.0.10240",
"PhoneNumber": "",
"LastSeen": "2016-05-03T10:54:07.650",
"EnrollmentStatus": "Unenrolled",
"ComplianceStatus": "NotAvailable",
"CompromisedStatus": false,
"LastEnrolledOn": "2016-01-29T16:41:57.760",
"LastComplianceCheckOn": "0001-01-01T00:00:00.000",
"LastCompromisedCheckOn": "0001-01-01T00:00:00.000",
"IsSupervised": false,
"DeviceMCC": {
"SIMMCC": "",
"CurrentMCC": ""
},
"AcLineStatus": 0,
"VirtualMemory": 0,
"Id": {
"Value": 23545
}
}
],
"Page": 0,
"PageSize": 500,
"Total": 13}
To something like:
{"name": "Devices",
"children": [
{"name":"Udid", "size":"7f0dsda63274692ea4f0b66fec67a020158"},
{"name":"SerialNumber", "size":"P988KJSPQF938"},
{"name":"MacAddress", "size":"1HJUSUD031C4"},
{"name":"Imei", "size":""},
{"name":"EasId", "size":"ApKJSPQF193"},
{"name":"AssetNumber", "size":"7f0cda636b3305fea4f0b66fec9997267a020158"},
{"name":"DeviceFriendlyName", "size":"TMcKenz iPad iOS 7.1.4 F193 "},
{"name":"LocationGroupId",
"children": [
{"name":"Id","size":7488},
{"name":"Name","size":"MCM"}
]
},
{"name":"UserId",
"children": [
{"name":"Id","size":6418},
{"name":"Name","size":"Tom McKenz"}
]
},
{"name":"UserName", "size":"TMcKenz"},
{"name":"UserEmailAddress", "size":"TMcKenz#awaw.com"}
]
}
Not sure what is the best practice here: is it possible to use D3.nest or do you need to iterate through all the nodes and change to 'name' and 'children' accordingly.
I would like to retrieve all versions of a page in Confluence. There is a call in the REST API that claims to return the history, but I have little luck with it.
/rest/api/content/{id}/history
When I call this I get a response along these lines:
{"latest": true,
"createdBy": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/.../profilepics/Avatar-14.png",
"width": 48,
"height": 48,
"isDefault": false
},
"username": "first.last#abc123.com",
"displayName": "First Last",
"userKey": "userKey"
}, "createdDate": "2014-12-29T13:56:16.000+0100", "_links": {
"base": "https://host.abc123.net/confluence",
"context": "/confluence",
"self": "host.abc123.net/confluence/rest/api/content/12345678/history"
}, "_expandable": {
"lastUpdated": ""
}}
I know that this page has 17 versions in the history through the browser interface. I can't seem to get anywhere by adding any kind of expand= to the query either.
The documentation for Confluence REST API tells me that this call should:
Returns a full JSON representation of the content's history
If I turn to the "normal" REST API call to retrieve content, I can get some hint about the history in the version structure:
{"version": {
"by": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/5639/.../profilepics/default.png",
"width": 48,
"height": 48,
"isDefault": true
},
"username": "some.other#abc123",
"displayName": "Some Other",
"userKey": "userKeyGuidThingy"
},
"when": "2015-01-30T16:00:09.000+0100",
"message": "",
"number": 17,
"minorEdit": false
} }
I am very keen on retrieving the other versions, numbers 1 - 16, but I can't see how..
I'd be most grateful for any help to get me unstuck.. :)
Here is an example:
Request:
http://localhost:8090/rest/experimental/content/7965952/version?expand=content
Response:
{
"results": [
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:29.000+03:00",
"message": "more stuff",
"number": 6,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "current",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/display/S1/cla1",
"tinyui": "/x/AI15",
"self": "http://localhost:8090/rest/api/content/7965952"
},
"_expandable": {
"container": "/rest/api/space/S1",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/6"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:12.000+03:00",
"message": "stuff",
"number": 5,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965962",
"tinyui": "/x/Co15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=5"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=5",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/5"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:28.000+03:00",
"message": "",
"number": 4,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965961",
"tinyui": "/x/CY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=4"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=4",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/4"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:12.000+03:00",
"message": "",
"number": 3,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965959",
"tinyui": "/x/B415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=3"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=3",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/3"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:38:36.000+03:00",
"message": "",
"number": 2,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965957",
"tinyui": "/x/BY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=2"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=2",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/2"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:23:14.000+03:00",
"message": "",
"number": 1,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965955",
"tinyui": "/x/A415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=1"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=1",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/1"
}
}
],
"start": 0,
"limit": 100,
"size": 6,
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version?expand=content",
"base": "http://localhost:8090",
"context": ""
}
}
this will get you all versions of a page with version messages
I found the way to get version number.
so If you go to https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history. You will get the following json response.
{
"previousVersion":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":1,
"minorEdit":false
},
"lastUpdated":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":2,
"minorEdit":false
},
"latest":true,
"createdBy":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"createdDate":"userkey",
"_links":{
"base":"https://confluence.yourdomain.com",
"context":"",
"self":"https://confluence.yourdomain.com/rest/api/content/page_id/history"
}
}
From that response json just fetch the version number depends on the scripting language that you are using. For Python following the piece of code will fetch the version number.
version=requests.get(https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history)
version= version.json()
print version['lastUpdated']['number']
This will give you latest version number of the page.