Abrahe
Abrahe

Reputation: 21

Can't curl post with JSON to a remote machine: "was expecting double-quote to start field name"

I'm trying to post a trace to a remote machine by giving the trace path and name as parameters in the curl command like this:

sshpass -p password ssh username@ip_adress "curl -X POST -d '{"parameters":{"name":"trace","uri":"/usagers4/username/Documents/Bench_1/kernel"}}' http://0.0.0.0:8080/tsp/api/traces -H Accept:application/json -H Content-Type:application/json"

But I'm getting the following error:

javax.servlet.ServletException: org.glassfish.jersey.server.ContainerException: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('p' (code 112)): was expecting double-quote to start field name| at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 3]

Does anyone have an idea about what I'm doing wrong ?

Thanks

Upvotes: 2

Views: 492

Answers (1)

Hack Lag
Hack Lag

Reputation: 1

I Solved! i'm need to get out for python use os.system(Curl ... ) it command return code 112 double quote to start field name i'm use os.system("curl -d '{\"agr\" : value}' -H 'value' -H 'value' ... etc.") you should use the following code

"curl -X POST -d '{\"parameters\":{\"name\":\"trace\",\"uri\":\"/usagers4/username/Documents/Bench_1/kernel\"}}' http://0.0.0.0:8080/tsp/api/traces -H 'Accept:application/json' -H 'Content-Type:application/json'"

Upvotes: 0

Related Questions