Problem when setting entity in httppost using Java

Asked

Viewed 25 times

0

I’ve been trying to replace a library for hours, can someone help me? I believe that due to lack of jar compatibility, my system is not accepting the following line of code:

httpPost.setEntity(entity);

That is, the problem is time to set the entity in httpPost. It just doesn’t run after that line. As an entity, I’m doing it this way:

StringEntity entity = new StringEntity(json.toString());

I would like to know if anyone knows any way to set the entity otherwise, or if, there is another library that I can use instead of Httppost. I have no experience in Rest services and therefore doubt. I have searched in several places but I found nothing to help me.

As for the jar, I am using httpclient and httpcore and testing several versions did not help: Versions with no success: 4.5.13, 4.5.12, 4.2.3, 4.5.10, 4.4.

Obs.: Error capture: org/apache/http/Httpentity

Can anyone help? Thanks in advance!!!

  • you put there that the error capture is "org/apache/http/Httpentity" but what is the description of the error?

  • Lucas, I don’t know why but capturing the errors in the following ways the return is just these: System.out.println(e.getMessage()); System.out.println(e.getStackTrace(); System.out.println(e.getLocalizedMessage()); org/apache/hc/client5/http/impl/classic/Httpclients [Ljava.lang.Stacktraceelement;@42bfc967 org/apache/hc/client5/http/impl/classic/Httpclients Note: I am trying version 5 now... and nothing new

No answers

Browser other questions tagged

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