cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: posting a JSON-list, syntax ?

From: Charles Romestant <cromestant_at_gmail.com>
Date: Tue, 14 Apr 2015 09:31:13 -0400

On Mon, Apr 13, 2015 at 5:46 PM, Ingimar <inkimar_at_gmail.com> wrote:

> Hello,
>
> I am posting a json to a java-backen. I am using Wildfly version 8.2
> This works fine.
> My method is decorated with the following annotation :
>
> @Consumes(MediaType.APPLICATION_JSON)
>
> @Produces(MediaType.APPLICATION_JSON)
>
>
> Now I would like to replace a String with a List of Strings.
> Having problem with the syntax
>
> My example looks like this right now :
>
> curl -v -H "Accept: application/json" -H "Content-type: application/json"
>> -X POST -d '{"owner":"malcolm","access":"public","licenseType":"CC
>> BY","legend":"this is
>> peter","fileName":"tosh.jpg","tags":"view=left&music=reggea"}'
>> http://127.0.0.1:8080/service/media
>
>
> I want to change "tags":"view=left&music=reggea" to the below ( the idea
> is "key":"value" )
>
> And do the below ( inspiration from
> https://jersey.java.net/documentation/1.18/json.html )
> I do not reach wildfly, the log is quiet
>
> curl -v -H "Accept: application/json" -H "Content-type: application/json"
>> -X POST -d '{"owner":"malcolm","access":"public","licenseType":"CC
>> BY","legend":"this is peter","fileName":"tosh.jpg",*"tags":[{"view":"left","music":"reggea"}]
>> *}' http://127.0.0.1:8080/service/media
>
>
> I do not get in touch with my service , this is the reply
>
> * Hostname was NOT found in DNS cache
>
> * Trying 127.0.0.1...
>
> * Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
>
> > POST /service/media HTTP/1.1
>
> > User-Agent: curl/7.35.0
>
> > Host: 127.0.0.1:8080
>
> > Accept: application/json
>
> > Content-type: application/json
>
> > Content-Length: 149
>
> >
>
> * upload completely sent off: 149 out of 149 bytes
>
> < HTTP/1.1 400 Bad Request
>
> < Connection: keep-alive
>
> < X-Powered-By: Undertow/1
>
> * Server WildFly/8 is not blacklisted
>
> < Server: WildFly/8
>
> < Content-Type: application/json
>
> < Content-Length: 0
>
> < Date: Mon, 13 Apr 2015 23:39:07 GMT
>
> <
>
> * Connection #0 to host 127.0.0.1 left intact
>
>
> any ideas ?
>
> Regardds, i
>
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-users
> FAQ: http://curl.haxx.se/docs/faq.html
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
>

-- 
MSc. Charles M. Romestant F.
Merci de penser à l'environnement avant d'imprimer cet e-mail
Please think about the environment before you print this e-mail
Por favor piense en el medio ambiente antes de imprimir este e-mail
Hello,
I see nothing wrong with your call. What you are posting is a simple json
with an array object. It is perfectly valid. I would verify that you have
nothing wrong in the app server procesing  , although the 400 error code
does imply something wrong with the request, it is probably on the
receiving end. I tested your request with an echo server and it is perfect
( as expected).

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-04-14