【问题标题】:Angular 4 API HttpClient Post/Get in ZomatoZomato 中的 Angular 4 API HttpClient 发布/获取
【发布时间】:2018-05-09 06:23:29
【问题描述】:

我有这个功能,但 zomato 一直将它返回为 403(无效的 API)。我不确定是否需要其他功能/参数来填充用户密钥

url='https://developers.zomato.com/api/v2.1/search?count=50&lat=111&lon=111&radius=1500&order=desc'
sendGetRequest() {
             const headers = new HttpHeaders()
                 .set('cache-control', 'no-cache')
                 .set('content-type', 'application/json')
                 .set('user-key', 'mykeygoeshere')

             return this.httpClient
                        .get(this.url, '', { headers: headers })
                        .subscribe(res => res.json);
    }   

【问题讨论】:

  • 根据网页描述,您需要生成 API 密钥。你有钥匙吗?
  • 您是否尝试过使用 Postman 或 curl 等 REST 工具的请求?
  • 密钥在 php Curl @PrasadBonthu 上正常工作

标签: angular angular-httpclient zomato-api


【解决方案1】:

我已经通过生成 API 密钥尝试了搜索请求并获得了成功的响应。所以你需要有一个合适的 API 密钥。

请求:

curl -X GET --header "Accept: application/json" --header "user-key: a2716934XXXXXXXXXXXX21ced1a5a35" "https://developers.zomato.com/api/v2.1/search"

回应:

{
  "results_found": 1272959,
  "results_start": 0,
  "results_shown": 20,
  "restaurants": [
    {
      "restaurant": {
        "R": {
          "res_id": 17842104
        },
        "apikey": "a2716934XXXXXXXXXXXX21ced1a5a35",
        "id": "17842104",
        "name": "Mr.",

【讨论】:

    猜你喜欢
    • 2018-06-20
    • 2018-11-14
    • 2018-01-26
    • 1970-01-01
    • 2020-04-22
    • 2018-07-05
    • 2018-07-31
    • 2017-09-29
    • 1970-01-01
    相关资源
    最近更新 更多