Hi Marcus
Below is the JSON request and response and I am using version 5.1.2. and the resolution provided by you for counting cancellation policy
"def Cancellationpolicy = context.expand( '${BlockRoomFixedBE#ResponseAsXml#count(//*:BlockRoomResult/*:HotelRoomsDetails[0]/*:CancellationPolicies)}' )" is not working it is giving me count 0 and on the same time I am using count assertion its giving me count 8.Please refer the screen shot for the same and important thing is I dont want to use assertions,I am using groovy scripting and I want to use count there ,like I was using count in Xpath
"def CancellationPolicies = context.expand( '${BE RoomDetails#ResponseAsXml#declare namespace ns1=\'
http://iapi.tbotechnology.in/searchrequest/\'; count(//ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e['+m+']/ns1:CancellationPolicies[1]/ns1:e)}' )"
Please provide the solution that why Json that I am providing is not getting converted into xml and how to apply count in JSON using Grrovy scripting
JSON Request:{
"AgencyId": 8428,
"ResultIndex": 1,
"HotelCode": "${BE Request#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:HotelSearchResult[1]/ns1:HotelResults[1]/ns1:e[1]/ns1:HotelCode[1]}",
"HotelName": "${BE Request#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:HotelSearchResult[1]/ns1:HotelResults[1]/ns1:e[1]/ns1:HotelName[1]}",
"GuestNationality": "IN",
"NoOfRooms": 4,
"ClientReferenceNo": 0,
"HotelRoomsDetails": [
{
"RoomIndex": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:RoomCombinations[1]/ns1:RoomCombination[1]/ns1:e[3]/ns1:RoomIndex[1]/ns1:e[1]}",
"RoomTypeCode": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:RoomTypeCode[1]}",
"RoomTypeName": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:RoomTypeName[1]}",
"RatePlanCode": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:RatePlanCode[1]}",
"BedTypeCode": null,
"SmokingPreference": 0,
"Supplements": null,
"Price": {
"RoomPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:RoomPrice[1]}",
"Tax": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:Tax[1]}",
"ExtraGuestCharge": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:ExtraGuestCharge[1]}",
"ChildCharge": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:ChildCharge[1]}",
"OtherCharges": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:OtherCharges[1]}",
"Discount": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:Discount[1]}",
"PublishedPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:PublishedPrice[1]}",
"PublishedPriceRoundedOff": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:OfferedPriceRoundedOff[1]}",
"OfferedPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:OfferedPrice[1]}",
"OfferedPriceRoundedOff": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:OfferedPriceRoundedOff[1]}",
"AgentCommission": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:AgentCommission[1]}",
"AgentMarkUp": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:AgentMarkUp[1]}",
"ServiceTax": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:ServiceTax[1]}",
"TDS": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[3]/ns1:Price[1]/ns1:TDS[1]}"
},
"HotelPassenger": [
{
"Title": "mr",
"Firstname": "Rohit",
"Middlename": null,
"Lastname": "Bisariya",
"Phoneno": null,
"Email": null,
"PaxType": 1,
"LeadPassenger": true,
"Age": 0,
"PassportNo": null,
"PassportIssueDate": null,
"PassportExpDate": null
},
{
"Title": "mr",
"Firstname": "Rohit",
"Middlename": "two",
"Lastname": "Bisariya",
"Phoneno": null,
"Email": null,
"PaxType": 2,
"LeadPassenger": false,
"Age": 12,
"PassportNo": null,
"PassportIssueDate": null,
"PassportExpDate": null
},
{
"Title": "mr",
"Firstname": "Rohit",
"Middlename": "two",
"Lastname": "Bisariya",
"Phoneno": null,
"Email": null,
"PaxType": 2,
"LeadPassenger": false,
"Age": 16,
"PassportNo": null,
"PassportIssueDate": null,
"PassportExpDate": null
}
]
},
{
"RoomIndex": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:RoomCombinations[1]/ns1:RoomCombination[1]/ns1:e[4]/ns1:RoomIndex[1]/ns1:e[1]}",
"RoomTypeCode": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:RoomTypeCode[1]}",
"RoomTypeName": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:RoomTypeName[1]}",
"RatePlanCode": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:RatePlanCode[1]}",
"BedTypeCode": null,
"SmokingPreference": 0,
"Supplements": null,
"Price": {
"RoomPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:RoomPrice[1]}",
"Tax": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:Tax[1]}",
"ExtraGuestCharge": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:ExtraGuestCharge[1]}",
"ChildCharge": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:ChildCharge[1]}",
"OtherCharges": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:OtherCharges[1]}",
"Discount": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:Discount[1]}",
"PublishedPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:PublishedPrice[1]}",
"PublishedPriceRoundedOff": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:OfferedPriceRoundedOff[1]}",
"OfferedPrice": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:OfferedPrice[1]}",
"OfferedPriceRoundedOff": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:OfferedPriceRoundedOff[1]}",
"AgentCommission": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:AgentCommission[1]}",
"AgentMarkUp": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:AgentMarkUp[1]}",
"ServiceTax": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:ServiceTax[1]}",
"TDS": "${BE RoomDetails#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:GetHotelRoomResult[1]/ns1:HotelRoomsDetails[1]/ns1:e[4]/ns1:Price[1]/ns1:TDS[1]}"
},
"HotelPassenger": [
{
"Title": "mr",
"Firstname": "Rohit",
"Middlename": null,
"Lastname": "Bisariya",
"Phoneno": null,
"Email": null,
"PaxType": 1,
"LeadPassenger": true,
"Age": 0,
"PassportNo": null,
"PassportIssueDate": null,
"PassportExpDate": null
}
]
}
],
"EndUserIp": "123.1.1.1",
"TokenId": "${LOGIN (Authenticate)#Response#declare namespace a='SharedServices'; declare namespace ns1='
http://tempuri.org/'; //ns1:AuthenticateResponse[1]/ns1:AuthenticateResult[1]/a:TokenId[1]}",
"ClientId": "nishant",
"TokenAgencyId": 8428,
"TokenMemberId": 9611,
"TraceId": "${BE Request#ResponseAsXml#declare namespace ns1='
http://iapi.tbotechnology.in/searchrequest/'; //ns1:Response[1]/ns1:HotelSearchResult[1]/ns1:TraceId[1]}"
}
JSON Response
{"GetBookingResult": {
"TraceId": "",
"ResponseStatus": 2,
"Error": {
"ErrorCode": 2,
"ErrorMessage": "Object reference not set to an instance of an object."
},
"BookingRefNo": null,
"ConfirmationNo": null,
"Status": 0
}}