Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RestTemplate, Spring boot , POST

I have a rest api at localhost:8086/addMessage and it works when I test it using POSTMAN. But when I want to integrate this api on client side it returns:

java.net.URISyntaxException: Expected scheme-specific part at index 10: localhost:
    at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_171]  error:

This is my method that calls api:

  public void addOrder(Message orders) throws  Exception
    {  RestTemplate restTemplate = new RestTemplate();
      String resp = restTemplate.postForObject(
                "localhost:8086/addMessage",
                orders,
                String.class);    
    }

How can I solve it.

like image 500
John Lenon Avatar asked Dec 15 '18 11:12

John Lenon


1 Answers

Add 'http' scheme to your url,

http://localhost:8086/addMessage

like image 184
stacker Avatar answered Nov 15 '22 09:11

stacker