I\'m new to Spring and trying to do a rest request with RestTemplate. The Java code should do the same as below curl command:
curl --data \"name=feature&colo
You need to set the Content-Type to application/json. Content-Type has to be set in the request. Below is the modified code to set the Content-Type
final String uri = "https://someserver.com/api/v3/projects/1/labels";
String input = "US";
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
headers.add("PRIVATE-TOKEN", "xyz");
HttpEntity request = new HttpEntity(input, headers);
ResponseEntity response = restTemplate.postForObject(uri, request, LabelCreationResponse.class);
Here, HttpEntity is constructed with your input i.e "US" and with headers. Let me know if this works, if not then please share the exception. Cheers!