首页 文章

如何修复错误“不支持的媒体类型”与邮递员发送通知

提问于
浏览
2

我尝试使用 Kaa 沙箱与 Postman 发送通知;但是给出了错误(不支持的媒体类型)。

我尝试使用标题**“Content-type”**:

  • application/json

  • Octed-Steram

但没有解决这个问题。

场景是:

第一个 - 架构结构是:

{
    "type": "record",
    "name": "Notification",
    "namespace": "org.kaa.config",
    "fields": [
        {
            "name": "message",
            "type": "string"
        }
    ]
}

第二 - 数据参数是:

{"applicationId":"111","schemaId":"139","topicId":"171","type":"USER"}

(提示:根据我的 required.)的值

第三

Json 文件争辩的是:

{
  "message" : "Hello world!"
}

这是 Postman 中的错误:

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>Error 415 Unsupported Media Type</title>
</head>
<body>
    <h2>HTTP ERROR 415</h2>
    <p>Problem accessing /kaaAdmin/rest/api/sendUnicastNotification. Reason:

        <pre>    Unsupported Media Type</pre>
    </p>
    <hr>
    <i>
        <small>Powered by Jetty://</small>
    </i>
    <hr/>
</body>

我尝试使用 cURL 命令但给出了相同的错误(不支持的媒体类型)

curl -v -S -u devuser:devuser123 -F'notification={"applicationId":"111","schemaId":"139","topicId":"171","type":"USER"};type=application/json' -F file=@notification.json "http://localhost:8080/kaaAdmin/rest/api/sendNotification" | python -mjson.tool

(提示:我尝试使用 Sandbox 中的 Notification Demo)。

这是参考链接:

http://docs.kaaproject.org/display/KAA/Admin REST API#AdminRESTAPI-Sendnotification

1 回答

  • 0

    邮差

    或者在您的通知正文模式中,任何字段都是可选的。你需要改变你的 json 文件。例如:

    {“notifId”:“16243”,“notifInfo”:{“string”:“this is info”},“notifType”:90,“notifPayload”:“这是有效载荷”}

    notifInfo 是可选

相关问题