2015-02-21 10 views
12

Sono in esecuzione il seguente comando nel prompt di Windows:di Windows: ricciolo con i dati JSON sulla riga di comando

curl -XPUT http://127.0.0.1:9200/test-index/test-type/_mapping?pretty=true -d '{"test-type": {"properties": {"name": {"index": "analyzed", "term_vector": "with_positions_offsets", "boost": 1.0, "store": "yes", "type": "string"}}}}' 

ottengo il seguente errore:

{ 
    "error" : "ElasticsearchParseException[Failed to parse content to map]; nested: JsonParseException[Unexpected character (''' (code 39)): expected a 
valid value (number, String, array, object, 'true', 'false' or 'null')\n at [Source: [email protected]5 
4ed1d2; line: 1, column: 2]]; ", 
    "status" : 400 
} 

ho cercato soluzioni e hanno trovato alternative come mettere dati json nei file, ma non posso usarlo per qualche motivo.

Grazie!

+2

provare a usare "" 'e sfuggire a quelli interni con' \ "'. –

+1

@ DanielA.White Questa dovrebbe essere una risposta. Con Windows, questo è un must –

+0

@ DanielA.White, che funziona! Potresti postarlo come risposta? – curious1

risposta

17

Windows cmd non supporta le stringhe con virgolette singole. Utilizzare " e sfuggire agli interni con \".

+0

Grazie! Mi aiuta molto. –

5

"I searched for solutions and found alternatives such as put json data in files, but I cannot use it for some reasons"

Questo dovrebbe funzionare, con hello.json in temperatura. @ è richiesto.

c:\temp>curl -v -X PUT \ 
      --data "@hello.json" \ 
      -H "Content-Type:application/json" \ 
      http://localhost:8080/api/myresource 
+1

Grazie per le informazioni! – curious1

Problemi correlati