Json via POST giving error

Asked

Viewed 55 times

1

Hello! I am sending a Json through an Httpclient and it is returning an error about header. Does anyone know what might be?

JsonDeDados = sender.sendMessageDATA();
            List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
            urlParameters.add(new BasicNameValuePair(infos, JsonDeDados));
            StringEntity entity = new StringEntity(JsonDeDados);

            post.setEntity(entity);

1 answer

1


Header declaration is missing

JsonDeDados = sender.sendMessageDATA();
            List<NameValuePair> urlParameters = new ArrayList<NameValuePair>();
            urlParameters.add(new BasicNameValuePair(infos, JsonDeDados));
            StringEntity entity = new StringEntity(JsonDeDados);

            post.setEntity(entity);
            post.setHeader("Content-Type", "application/json");

Test and tell us if it worked

  • It worked! Thank you. I wonder if that’s all that was missing?

  • If you incremented only this line and the code returned a positive response, possibly yes

Browser other questions tagged

You are not signed in. Login or sign up in order to post.