【问题标题】:Kaa - unable to create Configuration Schema with REST apiKaa - 无法使用 REST api 创建配置模式
【发布时间】:2017-04-20 07:00:48
【问题描述】:

我试图使用提供的其余 api 创建配置架构。执行给定的 curl 命令时出现以下错误。请帮忙。 抱歉,我不得不掩盖一些信息。

C:\xxxx>curl -v -S -u test:test123 -F'configuration
Schema={"applicationId":"32768","name":"Test configuration schema","description"
:"Configuration Schema Description"};type=application/json' -F file=@configurati
onschema.json "http://xx.xx.xx.xx:8080/kaaAdmin/rest/api/configurationSchema"
 | python -mjson.tool
*   Trying xx.xx.xx.xx...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*
Connected to xx.xx.xx.xx (xx.xx.xxx.xx) port 8080 (#0)
* Server auth using Basic with user 'test'
* WARNING: Using weak random seed
> POST /kaaAdmin/rest/api/configurationSchema HTTP/1.1
> Host: xx.xx.xx.xx:8080
> Authorization: Basic c3JlZTp0ZXN0MTIz
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Length: 750
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------df9c304eed
a5285e
>
  0   750    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0*
Done waiting for 100-continue
} [407 bytes data]
100   750    0     0  100   750      0     46  0:00:16  0:00:16 --:--:--     0<
HTTP/1.1 404 Not Found
< Date: Tue, 18 Apr 2017 05:04:20 GMT
< Set-Cookie: JSESSIONID=1nlr86kwwgbv612ia314pqj68w;Path=/
< Content-Type: text/html; charset=ISO-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 321
< Server: Jetty(9.2.2.v20140723)
* HTTP error before end of send, stop sending
<
{ [321 bytes data]
100  1071  100   321  100   750     19     45  0:00:16  0:00:16 --:--:--     0
* Closing connection 0
No JSON object could be decoded

【问题讨论】:

    标签: kaa


    【解决方案1】:

    看来您使用的是不同的 API。要上传配置架构,您应该使用/kaaAdmin/rest/api/saveConfigurationSchema。请参阅 API 文档here

    【讨论】:

    • 感谢您指出这一点。以前服务器 REST API 页面是空的。所以,我不得不使用this link。现在我使用了新的 API,它不再将 Configuration Schema .json 文件作为参数。相反,看起来我必须首先创建租户 CTL,并为配置架构使用 CTL 架构 ID。但是,尽管租户 ID 和经过身份验证的用户匹配,但现在我为“创建 CTL 架构”得到 403。请帮忙。
    • 从文档看,当认证用户不具备所需角色(TENANT_DEVELOPER 或 TENANT_USER)或应用程序的租户 ID 与认证用户的租户 ID 不匹配时,会返回 HTTP 403用户。 我对 Kaa REST API 的尝试不多。我可以知道你为什么不尝试对管理 UI 做同样的事情吗?
    • 我正在尝试通过脚本配置我的应用程序。我已经使用 UI 在一台服务器上执行此操作,并且一切正常。现在我想编写应用程序的配置脚本,并避免手动过程。我正在使用 python 和 requests 模块。
    • 我这样做是为了创建 CTL " 192.168.56.1:8080/kaaAdmin/rest/api/CTL/saveSchema?body={'namespace': 'org.hitachi.kaasample.schema', 'type': 'record', 'name': 'ConfigurationSchema', ' fields': [{'displayName': 'sample period', 'by_default': 1, 'type': 'int', 'name': 'sampleperiod'}]}&tenantId=1&applicationToken=49424475049782446707 ", 我使用的是 Kaa 沙箱.因此,租户用户为“admin/admin123”,租户 ID 为 1。
    • 我认为这些凭据是 TENANAT ADMIN 的。
    猜你喜欢
    • 2018-10-12
    • 1970-01-01
    • 2017-11-20
    • 1970-01-01
    • 2015-08-11
    • 1970-01-01
    • 2020-10-30
    • 2019-09-01
    • 2020-01-26
    相关资源
    最近更新 更多