Select to view content in your preferred language

Problem with Request on addFeature rest using httppost java

5868
1
01-27-2015 10:54 AM
MatheusCarvalho
Deactivated User

Hello,
I'm Trying to add a new Feature on my Server,but i'm having some problems

theres my code :

ArrayList<NameValuePair> postParameters;
  postParameters = new ArrayList<NameValuePair>();
     postParameters.add(new BasicNameValuePair("features", gson.toJson(UploadTasks.get("addFeatures"))));
     postParameters.add(new BasicNameValuePair("gdbVersion", "SDE.DEFAULT"));
     postParameters.add(new BasicNameValuePair("rollbackOnFailure", "true"));
     postParameters.add(new BasicNameValuePair("f", "pjson"));

HttpPost httppost = new HttpPost(urlsvaluepairs.getKey() + index + "/addFeatures");
  httppost.setEntity(new UrlEncodedFormEntity(postParameters));
  httppost.setHeader("Accept", "application/json");
  httppost.setHeader("Content-type", "application/json");
  try {
  String Res = httpclient.execute(httppost, new BasicResponseHandler());
  } catch (NetworkOnMainThreadException e) {
  e.printStackTrace();
  }
  //UpdateNewFeatures
  httppost = new HttpPost(urlsvaluepairs.getKey() + index + "/addFeatures?f=pjson");
  httppost.setEntity(new ByteArrayEntity(gson.toJson(UploadTasks.get("updateFeatures")).replace("\\", "").getBytes("UTF8")));
  httppost.setHeader("Accept", "application/json");
  httppost.setHeader("Content-type", "application/json");
  try {
  String Res = httpclient.execute(httppost, new BasicResponseHandler());
  } catch (NetworkOnMainThreadException e) {
  e.printStackTrace();
  }

the error returned to me is :

Unable to complete operation. Parser error: Some parameters could not be recognized.

someone can help-me ?

thanks!

0 Kudos
1 Reply
GregStevenson
Regular Contributor

Hi, check for any text objects that are being sent as unicode instead of as strings.

0 Kudos