repos - Comment puis-je POST JSON données avec cURL

Mots clés : jsonrestspring-mvccurlhttp-headersjson

meilleur 5 Réponses repos - Comment puis-je POST JSON données avec cURL

vote vote

95

-H "Content-Type: application/json" 
curl --header "Content-Type: application/json" \   --request POST \   --data '{"username":"xyz","password":"xyz"}' \   http://localhost:3000/api/login 
vote vote

89

curl -H "Content-Type: application/json" --data @body.json http://localhost:8080/ui/webapp/conf 
vote vote

76

curl -i -X POST -H "Content-Type: application/json" -d '{"key":"val"}' http://localhost:8080/appname/path 
curl -i -X POST -H "Content-Type: application/json" -d "{\"key\":\"val\"}" http://localhost:8080/appname/path 
vote vote

69

$ resty http://127.0.0.1:8080/data #Sets up resty to point at your endpoing $ GET /blogs.json                  #Gets http://127.0.0.1:8080/data/blogs.json                                    #Put JSON $ PUT /blogs/2.json '{"id" : 2, "title" : "updated post", "body" : "This is the new."}'                                    # POST JSON from a file $ POST /blogs/5.json < /tmp/blog.json 
vote vote

56

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"id":100}' http://localhost/api/postJsonReader.do 
@RequestMapping(value = "/postJsonReader", method = RequestMethod.POST) public @ResponseBody String processPostJsonData(@RequestBody IdOnly idOnly) throws Exception {         logger.debug("JsonReaderController hit! Reading JSON data!"+idOnly.getId());         return "JSON Received"; } 

Questions similaires