Unsupported Media Type with json file

227 views
Skip to first unread message

Mahdieh Asiaban

unread,
Aug 2, 2017, 12:13:02 AM8/2/17
to Kaa project


Hi.

I try send Notification  with Postman but given an error (Unsupported Media Type).

First structure of schema is : 

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

Second data param is:

{"applicationId":"111","schemaId":"139","topicId":"171","type":"USER"}
(Hint: value according of my required.)

Third:

File contend is:(Json file)
{
  "message" : "Hello world!"
}

I have attached screen shot of my probelem.
and i try with cURL command but given an same error (Unsupported Media Type)(hint: json file there is in the same folder with 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

(Hint: I trying with Notification Demo)
notification.json
image_DF.png
image_7A.png
image_Yw.png
Message has been deleted

Castle

unread,
Aug 4, 2017, 3:22:15 AM8/4/17
to Kaa project
-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

Your code looks like missing a space : -F 'notification...' not -F'notification...'

Mahdieh Asiaban

unread,
Aug 5, 2017, 12:29:02 AM8/5/17
to Kaa project
Thanks...

But give an error "Required request part 'notification' is not present"

and json file is in the folder cURL.

This is flow of my command:

curl -v -S -u devuser:devuser123 -F 'notification={"applicationId":"3","schemaId":"3","topicId":"65536","type":"USER"};type=application/json' -F file=@notification.json "http://localhost:8080/kaaAdmin/rest/api/sendNotification"
* timeout on name lookup is not supported
*   Trying 192.168.10.49...
* TCP_NODELAY set
* Connected to localhost (localhost) port 8080 (#0)
* Server auth using Basic with user 'devuser'
> POST /kaaAdmin/rest/api/sendNotification HTTP/1.1
> Host: localhost:8080
> Authorization: Basic ZGcjpkZXZ1c2VyMTIz
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Length: 430
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------9afb6dbc2f9b9ad9
>
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Required request part 'notification' is not present
< Date: Sun, 16 Jul 2017 10:22:14 GMT
< Set-Cookie: JSESSIONID=5ntlt6mc0q35137au4d7ilmzw;Path=/
< Content-Type: text/html; charset=ISO-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 402
< Server: Jetty(9.2.2.v20140723)
* HTTP error before end of send, stop sending
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 400 Required request part 'notification' is not present</title>
</head>
<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /kaaAdmin/rest/api/sendNotification. Reason:
<pre>    Required request part 'notification' is not present</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>
* Closing connection 0

Castle

unread,
Aug 6, 2017, 12:53:19 AM8/6/17
to Kaa project
You need to keep your command and your file on the same folder,
like:

Then you can use this command.

Mahdieh Asiaban

unread,
Aug 6, 2017, 3:28:26 AM8/6/17
to Kaa project
I keep my command and Json file on the same folder.

And I using windows; this command  (ls -al) not working on windows.

So, I try with command (dir -al) for windows, but given an error:

File Not Found

Please guide me for this command on windows.

Thanks.

Mahdieh Asiaban

unread,
Aug 6, 2017, 4:39:13 AM8/6/17
to Kaa project
I keep command and file on the same folder and give an error: 

C:\Users\80006\mycurl>curl -v -S -u devuser:devuser123 -F'notification={"applicationId":"3","schemaId":"3","topicId":"65536","type":"USER"};type=application/json'-F file=@notification.json "http://192.168.10.49:8080/kaaAdmin/rest/api/sendNotification"
* Rebuilt URL to: file=@notification.json/
* timeout on name lookup is not supported
*   Trying 104.239.213.7...
* TCP_NODELAY set
* Connected to notification.json (104.239.213.7) port 80 (#0)
* Server auth using Basic with user 'devuser'
> POST / HTTP/1.1
> Host: notification.json
> Authorization: Basic ZGV2dXNlcjpkZXZ1c2VyMTIz
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Length: 235
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------f99a348df70337a8
>
< HTTP/1.1 301 Moved Permanently
< Server: nginx
< Date: Sun, 06 Aug 2017 08:36:39 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: close
< Location: http://localhost
< Expires: Sun, 06 Aug 2017 08:36:38 GMT
< Cache-Control: no-cache
<
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx</center>
</body>
</html>
* Closing connection 0
* timeout on name lookup is not supported
*   Trying 192.168.10.49...
* TCP_NODELAY set
* Connected to 192.168.10.49 (192.168.10.49) port 8080 (#1)
* Server auth using Basic with user 'devuser'
> POST /kaaAdmin/rest/api/sendNotification HTTP/1.1
> Authorization: Basic ZGV2dXNlcjpkZXZ1c2VyMTIz
> User-Agent: curl/7.53.1
> Accept: */*
> Content-Length: 235
> Expect: 100-continue
> Content-Type: multipart/form-data; boundary=------------------------effc75c19be3801a
>
< HTTP/1.1 100 Continue
< HTTP/1.1 400 Required request part 'notification' is not present
< Date: Mon, 17 Jul 2017 14:35:41 GMT
< Set-Cookie: JSESSIONID=13yg61zr1jdbsjg66gea21kra;Path=/
< Content-Type: text/html; charset=ISO-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 402
< Server: Jetty(9.2.2.v20140723)
* HTTP error before end of send, stop sending
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Error 400 Required request part 'notification' is not present</title>
</head>
<body><h2>HTTP ERROR 400</h2>
<p>Problem accessing /kaaAdmin/rest/api/sendNotification. Reason:
<pre>    Required request part 'notification' is not present</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/>

</body>
</html>
* Closing connection 1
Message has been deleted

Mahdieh Asiaban

unread,
Aug 6, 2017, 5:31:21 AM8/6/17
to Kaa project

I have attached log file sandbox.
sanbodx_logs.rar
Reply all
Reply to author
Forward
0 new messages