Expedia酒店API

时间:2013-11-12 04:55:08

标签: c# asp.net

我正在使用Expedia酒店API.All该功能正在工作,除了预订。所有其他请求使用GET方法请求。但在预订时我们必须使用不同URL的POST方法。所以我更改了请求的URL但仍然得到错误。 我的代码是

 HotelServicesImplService client = new HotelServicesImplService();
    HotelRoomReservationRequest bookreq = new HotelRoomReservationRequest();
    HotelRoomReservationResponse bookres = new HotelRoomReservationResponse();
    addressInfo bookad = new addressInfo();
    reservationInfo bookinfo = new reservationInfo();
    client.Url = "https://book.api.ean.com/ean-services/rs/hotel/v3";

    //bookreq.minorRevSpecified = true;
    //bookreq.minorRev = 25;
    bookreq.hotelId = 106347;
    bookreq.apiKey = "api";
    bookreq.cid = "cid";
    bookreq.arrivalDate = "12/11/2013";
    bookreq.departureDate = "12/13/2013";
    bookreq.supplierType = SupplierType.E;
    bookreq.rateKey = "af00b688-acf4-409e-8bdc-fcfc3d1cb80c";
    bookreq.roomTypeCode = "198058";
    bookreq.rateCode = "484072";
    bookreq.RoomGroup = new[] { new Room
    {
        numberOfAdults=Convert.ToInt32(2),
        numberOfChildren=Convert.ToInt32(0),
        childAges=new int[] {} ,
        firstName="Test Booking",
        lastName="Test Booking",
        bedTypeId="23",
        smokingPreference=SmokingPreference.NS,
    }};
    float i = float.Parse("231.18");
    bookreq.currencyCode = "USD";
    bookreq.chargeableRate = i;
    bookinfo.email = "ranaabhi007@yahoo.com";
    bookinfo.firstName = "TestBooking";
    bookinfo.lastName = "TestBooking";
    bookinfo.homePhone = "2145370159";
    bookinfo.workPhone = "2145370159";
    bookinfo.creditCardType = "CA";
    bookinfo.creditCardNumber = "5401999999999999";
    bookinfo.creditCardIdentifier = "TestBooking";
    bookinfo.creditCardExpirationMonth = "12";
    bookinfo.creditCardExpirationYear = "2015";
    bookad.city = "Seattle";
    bookad.stateProvinceCode = "WA";
    bookad.countryCode = "US";
    bookad.postalCode = "98004";
    bookreq.ReservationInfo = bookinfo;
    bookad.address1 = "travelnow";
    //bookad.city = txtCity.Text;
    //bookad.stateProvinceCode = txtState.Text;
    //bookad.countryCode = txtCountry.Text;
    //bookad.postalCode = txtPostal.Text;
    bookreq.AddressInfo = bookad;
    bookres = client.getReservation(bookreq);
   // HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(client);
    Response.Write(bookres.confirmationNumbers);
    Response.Write(bookres.departureDate);
    Response.Write(bookres.drivingDirections);
    Response.Write(bookres.CouponInformationResponse);

但我仍然收到错误

The request failed with HTTP status 404: Not Found.

1 个答案:

答案 0 :(得分:0)

您确定自己的网址是否正确?根据{{​​3}},它应该是

https://book.api.ean.com/ean-services/rs/hotel/v3/res