我在skyscanner REST API中找不到trip结果

2024-09-20 05:43:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我获得以下错误:403,\n“消息”:“当我尝试使用Skyscanner REST API在Python中获取此请求时,缺少会话创建的基本定价访问权限。其他请求已正确解析

  data = {
  'cabinclass': 'Economy',
  'country': 'ES',
  'currency': 'EUR',
  'locale': 'es-ES',
  'locationSchema': 'iata',
  'originplace': '{origin}'.format(origin=originplace),
  'destinationplace': '{destination}'.format(destination=destinationplace),
  'outbounddate': '{y}-{m}-{d}'.format(y=str(date.year),m=str(date.month).zfill(2),d=str(date.day).zfill(2)),
  'inbounddate':'',
  'adults': '{numadul}'.format(numadul=nadults),
  'children': '{numchildren}'.format(numchildren=nchildren),
  'infants': '{numinfants}'.format(numinfants=ninfants),
  'apikey': 'myapiKey'
 }

headers = {
  'Content-Type': 'application/x-www-form-urlencoded',
}

 



response=requests.post('https://partners.api.skyscanner.net/apiservices/pricing/v1.0',headers=headers, data=data)

Tags: apiformatdatadateesorigindestinationheaders
1条回答
网友
1楼 · 发布于 2024-09-20 05:43:05

HTTP 403错误通常用于指示缺少权限。您收到的错误消息“缺少会话创建的基本定价访问权限”似乎也表明权限不足。这里的响应代码列表也支持缺少访问:https://skyscanner.github.io/slate/#response-codes

403 Forbidden The API Key was not supplied, or it was invalid, or it is not authorized to access the service.

我会尝试通过curl或类似Postman的工具运行请求,以确认它是您的API密钥,而不是您的代码。然后向API提供程序查询,以确定为什么您没有访问该端点的权限

相关问题 更多 >