当前位置:论坛首页 > Linux面板 > 求助

【已解答】面板 API 调用创建网站提示:出错了,

发表在 Linux面板2023-10-24 15:53 [复制链接] 4 2538

本帖最后由 堡塔运维香菜卷 于 2023-10-24 16:16 编辑

为了能快速了解并处理您的问题,请提供以下基础信息:
面板、插件版本: 7.7.0

系统版本:CentOS 7.9.2009 x86_64(Py3.7.9)

问题描述:api 调用创建网站

相关截图(日志、错误):
0|cos-server  |     <h3>出错了,面板运行时发生错误!</h3>
0|cos-server  |     <div style="margin-bottom: 15px;margin-top: 15px;color: red;">
0|cos-server  |         <h4 style="font-size: none;">AttributeError: 'dict_obj' object has no attribute 'path'</h4>
0|cos-server  |     </div>
0|cos-server  |     <pre style="height:165px;word-wrap: break-word;white-space: pre-wrap;margin: 0 0 10px">REQUEST_DATE: 2023-10-24 15:41:50
0|cos-server  |  PAN_VERSION: 7.7.0
0|cos-server  |   OS_VERSION: CentOS  7.9.2009 x86_64(Py3.7.9)
0|cos-server  |  REMOTE_ADDR: 175.11.90.177
0|cos-server  |  REQUEST_URI: POST /site?action=AddSite&request_token=b416b077c6c5bd4f91e5aa607766bcae&request_time=1698133311
0|cos-server  | REQUEST_FORM: {}
0|cos-server  |   USER_AGENT: axios/1.5.1</pre>
0|cos-server  |     <pre style="height:427px;word-wrap: break-word;white-space: pre-wrap;margin: 0 0 0px">Traceback (most recent call last):
0|cos-server  |   File "/www/server/panel/BTPanel/__init__.py", line 1640, in publicObject
0|cos-server  |     return run_exec().run(toObject, defs, get)
0|cos-server  |   File "/www/server/panel/BTPanel/__init__.py", line 1588, in run
0|cos-server  |     result = getattr(toObject,get.action)(get)
0|cos-server  |   File "class/panelSite.py", line 479, in AddSite
0|cos-server  |     get.path = self.__get_site_format_path(get.path)
0|cos-server  | AttributeError: 'dict_obj' object has no attribute 'path'</pre>
0|cos-server  |     <ul class="help-info-text">
0|cos-server  |         <li style="list-style: none;"><b>很抱歉,面板运行时意外发生错误,请尝试按以下顺序尝试解除此错误:</b></li>
0|cos-server  |         <li style="list-style: none;">1、在[首页]右上角点击修复面板,并退出面板重新登录。</li>
0|cos-server  |         <li style="list-style: none;">2、如上述尝试未能解除此错误,请截图此窗口到宝塔论坛发贴寻求帮助, 论坛地址:<a class="btlink" href="https://www.bt.cn/bbs" target="_blank">https://www.bt.cn/bbs</a></li>
0|cos-server  |     </ul>
修复也无效,这是什么问题

使用道具 举报 只看该作者 回复
发表于 2023-10-24 16:31:27 | 显示全部楼层
您好,“ AttributeError: 'dict_obj' object has no attribute 'path'” 这里缺少了path的路径,您在通过api创建站点是否缺少了关键的参数呢?
使用道具 举报 回复 支持 反对
发表于 2023-10-24 16:43:29 | 显示全部楼层
堡塔运维香菜卷 发表于 2023-10-24 16:31
您好,“ AttributeError: 'dict_obj' object has no attribute 'path'” 这里缺少了path的路径,您在通过a ...

没有缺少参数,跟面板操作参数一样,我刚刚升级之后调用接口现在报404了
0|cos-server  | <head><title>404 Not Found</title></head>
0|cos-server  | <body>
0|cos-server  | <center><h1>404 Not Found</h1></center>
0|cos-server  | <hr><center>nginx</center>
0|cos-server  | </body>
0|cos-server  | </html>
0|cos-server  | <html>
0|cos-server  | <head><title>404 Not Found</title></head>
0|cos-server  | <body>
0|cos-server  | <center><h1>404 Not Found</h1></center>
0|cos-server  | <hr><center>nginx</center>
0|cos-server  | </body>
0|cos-server  | </html>
使用道具 举报 回复 支持 反对
发表于 2023-10-24 16:50:30 | 显示全部楼层
本帖最后由 宝塔用_dd82 于 2023-10-24 16:54 编辑
宝塔用_dd82 发表于 2023-10-24 16:43
没有缺少参数,跟面板操作参数一样,我刚刚升级之后调用接口现在报404了
0|cos-server  | 404 Not Found
...

升级报错部分
Collecting Cheetah
  Downloading https://mirrors.aliyun.com/pypi/packages/cd/b0/c2d700252fc251e91c08639ff41a8a5203b627f4e0a2ae18a6b662ab32ea/Cheetah-2.4.4.tar.gz (190 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 191.0/191.0 kB 693.5 kB/s eta 0:00:00
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      Traceback (most recent call last):
        File "<string>", line 36, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-vcosbr3m/cheetah_0ebc84e5341b4183b2ad8468b3a52790/setup.py", line 10, in <module>
          import SetupTools
        File "/tmp/pip-install-vcosbr3m/cheetah_0ebc84e5341b4183b2ad8468b3a52790/SetupTools.py", line 50
          except DistutilsPlatformError, x:
                                       ^
      SyntaxError: invalid syntax
      [end of output]note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-fail
× Encountered error while generating package metadata.
╰─> See above for output.note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
--2023-10-24 16:17:43--  https://dg2.bt.cn/install/update/LinuxPanel-8.0.3.zip
Resolving dg2.bt.cn (dg2.bt.cn)... 103.179.243.14, 2001:19f0:7001:54fc:5400:2ff:fe9b:97f9
Connecting to dg2.bt.cn (dg2.bt.cn)|103.179.243.14|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 16396548 (16M) [application/zip]
Saving to: ‘/tmp/panel.zip’



使用道具 举报 回复 支持 反对
发表于 2023-10-25 16:32:05 | 显示全部楼层
宝塔用_dd82 发表于 2023-10-24 16:50
升级报错部分
Collecting Cheetah
  Downloading https://mirrors.aliyun.com/pypi/packages/cd/b0/c2d700 ...

已解决,确实是参数问题
我是使用axios 发送请求,不知道什么原因,相同的入参位置,验证字段能正常接收,某些字段死活不接收,老版本还会提示字段缺失啥的,新版本就只提示404,完全不知道错误原因

本来按照官方文档:所有响应内容统一为 Json 数据格式
我请求头数据类型是用了 "Content-Type": "application/json"
其实就是这里导致各种问题,后面调试保存nginx内容,数据内容过长也报404

解决办法
改成  "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"
数据使用formData格式化,以上问题解决了
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表