Api Response… Why am i having this mistake?

I am developing a flight search app using that interacts with the Priceline API through RapidAPI. The problem is that the API is not returning any flight results. I am also receiving a specific error message in the JSON response.

Code doing the API Call:

import Foundation

class FlightService {
  static let shared = FlightService()

  private init() {}

  private func createURLRequest(endpoint: String, parameters: [String: String]?) -> URLRequest? {
    var components = URLComponents(string: "https://priceline-com2.p.rapidapi.com/(endpoint)")

    if let params = parameters {
      components?.queryItems = params.map { URLQueryItem(name: $0.key, value: $0.value) }
    }

    guard let url = components?.url else { return nil }

    var request = URLRequest(url: url)
    request.addValue("application/json", forHTTPHeaderField: "Content-Type")
    request.addValue("application/json", forHTTPHeaderField: "Accept")
    request.addValue("xxxxxxxxxxxxxxxx", forHTTPHeaderField: "X-RapidAPI-Key")
    request.addValue("priceline-com2.p.rapidapi.com", forHTTPHeaderField: "X-RapidAPI-Host")

    return request
  }

  func searchFlightsRoundTrip(origin: String, destination: String, departureDate: String, returnDate: String, passengers: Int, classType: String) async throws -> [Flight] {
    let endpoint = "flights/search-roundtrip"
    let parameters = [
      "originAirportCode": origin,
      "destinationAirportCode": destination,
      "departureDate": departureDate,
      "returnDate": returnDate,
      "numberOfPassengers": String(passengers),
      "classType": classType
    ]

    print("Enviando parámetros a la API: (parameters)")

    guard let request = createURLRequest(endpoint: endpoint, parameters: parameters) else {
      throw URLError(.badURL)
    }

    let (data, response) = try await URLSession.shared.data(for: request)

    if let httpResponse = response as? HTTPURLResponse {
      print("HTTP Status Code: (httpResponse.statusCode)")
    }

    if let jsonString = String(data: data, encoding: .utf8) {
      print("Response JSON: (jsonString)")
    }

    do {
      let flightResponse = try JSONDecoder().decode(FlightResponse.self, from: data)

      if let flights = flightResponse.data?.searchItems {
        print("Flights received: (flights.count)")
        return flights
      } else {
        print("No flights found in the response.")
        return []
      }
    } catch {
      print("Error decoding flight data: (error)")
      throw error
    }
  }
}

Request I am sending to the API:

 {
  "originAirportCode": "MAD",
  "destinationAirportCode": "LON",
  "departureDate": "2024-09-30",
  "returnDate": "2024-10-15",
  "numberOfPassengers": "2",
  "classType": "ECO"
}

The API Response with the following JSON, which seems to indicate an error:

{
  "data": {
    "isFireFly": null,
    "airline": null,
    "airport": null,
    "listings": null,
    "expressDeal": null,
    "filterDefaults": null,
    "listingsMetaData": null,
    "travelInsurance": null,
    "error": {
      "code": null,
      "desc": null,
      "message": "Error while invoking the QueryExecutor.search Operation for component FLY in Error: com.priceline.usp.search.exception.QueryExecutorException: QueryExecutorService.search while calling component FLY, resulted in Error :  No Itineraries Found for Given Request , StatusCode:  ."
    },
    "displayableCarriers": null,
    "expressDealsCandidates": null,
    "brandReference": null
  },
  "meta": {
    "currentPage": 1,
    "limit": 0,
    "totalRecords": 0,
    "totalPage": 0
  },
  "status": true,
  "message": "Successful"
}

Here is the output from the console:

API: ["destinationAirportCode": "LON", "originAirportCode": "MAD", "numberOfPassengers": "2", "classType": "ECO", "departureDate": "2024-09-30", "returnDate": "2024-10-15"]
HTTP Status Code: 200
Response JSON: {"data":{"isFireFly":null,"airline":null,"airport":null,"listings":null,"expressDeal":null,"filterDefaults":null,"listingsMetaData":null,"travelInsurance":null,"error":{"code":null,"desc":null,"message":"Error while invoking the QueryExecutor.search Operation for component FLY in Error: com.priceline.usp.search.exception.QueryExecutorException: QueryExecutorService.search while calling component FLY, resulted in Error :  No Itineraries Found for Given Request , StatusCode:  ."},"displayableCarriers":null,"expressDealsCandidates":null,"brandReference":null},"meta":{"currentPage":1,"limit":0,"totalRecords":0,"totalPage":0},"status":true,"message":"Successful"}
No flights found in the response.

Problem:
Even though I am receiving a 200 OK status from the API, the response data contains no flight itineraries.
The error message in the response is vague: No Itineraries Found for Given Request.

Questions:

  • Why am I not getting any flight results from the API, and what does the error No Itineraries Found for Given Request mean in this context?
  • Are there any specific changes I need to make to my request parameters to resolve this issue?

1

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật