geofence creation using api issue

kirantpatil5 years ago

Hi,

Unable to create the geofence using below api. Please let me know what mistake am I doing here.

response = HTTParty.post("http://15.206.169.115:8082/api/geofences", :basic_auth => auth,:headers => {'Content-Type' => 'application/json', 'Accept' => 'application/json'}, :body => {'area' => 'CIRCLE(12.95929 77.53596, 100)', 'attributes' => "", 'CalenderId' => 0, 'description' => "mygeo", 'id' => 0 , 'name' => "kiran"}.to_json)

=> #<HTTParty::Response:0x5587fa360218 parsed_response="Cannot construct instance of java.util.LinkedHashMap (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('')\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 55] (through reference chain: org.traccar.model.Geofence[\"attributes\"])", @response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @headers={"connection"=>["close"], "date"=>["Sun, 12 Jan 2020 01:14:38 GMT"], "content-type"=>["text/plain"], "access-control-allow-headers"=>["origin, content-type, accept, authorization"], "access-control-allow-credentials"=>["true"], "access-control-allow-methods"=>["GET, POST, PUT, DELETE, OPTIONS"], "access-control-allow-origin"=>["*"], "content-length"=>["370"], "server"=>["Jetty(9.4.20.v20190813)"]}>

kirantpatil5 years ago

Now it works after changing as below.

response = HTTParty.post("http://15.206.169.115:8082/api/geofences", :basic_auth => auth,:headers => {'Content-Type' => 'application/json', 'Accept' => 'application/json'}, :body => {"area" => "CIRCLE(12.95929 77.53596, 100)", :attributes => {}, :description => "mygeo", "id" => -1 , :name => "kiran"}.to_json)