Error on external REST endpoint call using RestTemplate

webDev :

My Code breaks when it reaches to this line.

String resp = restTemplate.postForObject(URL, json, String.class);

On my localhost its working fine but on dev-env server, The error is:

Error occured in java.lang.NoSuchMethodError: com.microsoft.applicationinsights.agent.internal.coresync.impl.ImplementationsCoordinator.httpMethodFinished(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;IJ)V

The dev-env is Azure Application Service including Java 8 and Tomcat 9.

webDev :

I got the problem and solution (For others who will get exact same issue as posted): Problem: restTemplate.postForObject() was failing, there was conflict because I was using setConnectTimeout(10000); for

@Bean
public RestTemplate restTemplate(){
  return new RestTemplate(clientHttpRequestFactory());
}
private ClientHttpRequestFactory clientHttpRequestFactory(){
  HttpComponentsClientHttpRequestFactory .......
  factory.setConnectTime(...);
  return factory
}

The problem was solved when I removed clientHttpRequestFactory() from restTemplate and configured default without the connect timeout. Now it's not conflicting.

@Gaurav I will mark your answer because your response gave me an idea about the dependency conflict issue.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to make restTemplate.getForObject call for Mediatypes Rest endpoint

From Dev

How to call rest endpoint via Spring restTemplate that is protected by Keycloak

From Dev

Call an external Web Api REST endpoint using AWS Lambda invoked by a WorkMail event

From Dev

Quarkus with Camel call external endpoint. Error: Map at least one servlet to a path using quarkus.camel.servlet.url-patterns

From Dev

Calling Rest Endpoint with RestTemplate and Kotlin Data Class

From Dev

Call a endpoint which return a HashMap with RestTemplate

From Dev

Spring Integration: call REST endpoint using outbound gateway with oAuth?

From Java

Making a REST Call to Endpoint in Dockers

From Dev

Using UseEffect to Call an Endpoint

From Dev

Error while consuming REST Endpoint using Spring WebFlux Client

From Dev

Unauthorized error when using GitLab Private Token to call GitLab endpoint

From Dev

Run R script using sp_invoke_external_rest_endpoint on Azure SQL

From Dev

Firebase Google Cloud Function call external endpoint

From Dev

Avoid making actual Rest call in RestTemplate Junit

From Dev

How can I make a Put rest call along with POJO using RestTemplate

From Dev

Error while calling External REST URL from netsuite using token

From Java

How to inject Feign Client with out using Spring Boot and call a REST Endpoint

From Dev

Call a different REST endpoint per Gatsby Page

From Dev

Forbidden when RestTemplate call an external API (Cloudflare server)

From Dev

Error in using WebClient object REST API call using C#

From Java

Unable to consume a rest api using resttemplate

From Java

Basic authentication for REST API using spring restTemplate

From Dev

Unable to call Salesforce API using Spring RestTemplate

From Dev

How to call multiple hosts using RestTemplate

From Dev

sp_invoke_external_rest_endpoint :: Connections to the domain are not allowed

From Dev

Spring Boot REST webservice endpoint when provided external Tomcat

From Dev

403 Error when using fetch to call Cloudfront S3 endpoint with custom domain and signed cookies

From Dev

React-Native fetch call to localhost endpoint is giving Type Error: Network request failed when using https

From Dev

PayPal Rest API PHP Service endpoint error

Related Related

  1. 1

    How to make restTemplate.getForObject call for Mediatypes Rest endpoint

  2. 2

    How to call rest endpoint via Spring restTemplate that is protected by Keycloak

  3. 3

    Call an external Web Api REST endpoint using AWS Lambda invoked by a WorkMail event

  4. 4

    Quarkus with Camel call external endpoint. Error: Map at least one servlet to a path using quarkus.camel.servlet.url-patterns

  5. 5

    Calling Rest Endpoint with RestTemplate and Kotlin Data Class

  6. 6

    Call a endpoint which return a HashMap with RestTemplate

  7. 7

    Spring Integration: call REST endpoint using outbound gateway with oAuth?

  8. 8

    Making a REST Call to Endpoint in Dockers

  9. 9

    Using UseEffect to Call an Endpoint

  10. 10

    Error while consuming REST Endpoint using Spring WebFlux Client

  11. 11

    Unauthorized error when using GitLab Private Token to call GitLab endpoint

  12. 12

    Run R script using sp_invoke_external_rest_endpoint on Azure SQL

  13. 13

    Firebase Google Cloud Function call external endpoint

  14. 14

    Avoid making actual Rest call in RestTemplate Junit

  15. 15

    How can I make a Put rest call along with POJO using RestTemplate

  16. 16

    Error while calling External REST URL from netsuite using token

  17. 17

    How to inject Feign Client with out using Spring Boot and call a REST Endpoint

  18. 18

    Call a different REST endpoint per Gatsby Page

  19. 19

    Forbidden when RestTemplate call an external API (Cloudflare server)

  20. 20

    Error in using WebClient object REST API call using C#

  21. 21

    Unable to consume a rest api using resttemplate

  22. 22

    Basic authentication for REST API using spring restTemplate

  23. 23

    Unable to call Salesforce API using Spring RestTemplate

  24. 24

    How to call multiple hosts using RestTemplate

  25. 25

    sp_invoke_external_rest_endpoint :: Connections to the domain are not allowed

  26. 26

    Spring Boot REST webservice endpoint when provided external Tomcat

  27. 27

    403 Error when using fetch to call Cloudfront S3 endpoint with custom domain and signed cookies

  28. 28

    React-Native fetch call to localhost endpoint is giving Type Error: Network request failed when using https

  29. 29

    PayPal Rest API PHP Service endpoint error

HotTag

Archive