duanla8800 2018-06-12 14:06
浏览 327

Cloudflare安全级别没有从api改变

I am trying to change the security_level from curl for cloudflare api

$ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://api.cloudflare.com/client/v4/zones/zoneId/setings/security_level");
    curl_setopt($ch, CURLOPT_HEADER, array('X-Auth-Email'=>'Email','X-Auth-Key'=>'Api_key','Content-Type'=>'application/json'));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array('value' => 'MEDIUM'));
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $data = curl_exec($ch);

But i am getting error as given below:

{"success":false,"errors":[{"code":7003,"message":"Could not route to /zones/zoneId/settings/security_level, perhaps your object identifier is invalid?"},{"code":7000,"message":"No route for that URI"}],"messages":[],"result":null}

  • 写回答

1条回答 默认 最新

  • doudou20145 2019-02-20 15:48
    关注

    I got the same error when I tried to change security level through api. I was wondering how GET gives me correct result and PATCH command fails.

    For example:

    curl -v -X GET https://api.cloudflare.com/client/v4/zones/my_zone_id/settings/security_level \
    -H "X-Auth-Email: my_email" \
    -H "Content-Type:application/json" \
    -H "X-Auth-Key: my_Global_API_Key" | jq
    

    was giving me:

    {
      "result": {
        "id": "security_level",
        "value": "high",
        "modified_on": "2019-02-07T17:05:58.073422Z",
        "editable": true
      },
      "success": true,
      "errors": [],
      "messages": []
    }
    

    but:

    curl -X PATCH "https://api.cloudflare.com/client/v4/zones/my_zone_id/settings/security_level" \ 
    -H "X-Auth-Email: my_email" \
    -H "Content-Type:application/json" \
    -H "X-Auth-Key: my_Global_API_Key" \
    --data '{"value":"under_attack"}'
    

    was giving me:

    {"success":false,"errors":[{"code":7003,"message":"Could not route to \/zones\/my_zone_id\/settings\/security_level, perhaps your object identifier is invalid?"},{"code":7000,"message":"No route for that URI"
    

    Somehow I realized that the issue was in copy/paste. When I re-enter the PATCH command again, everything worked.

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化