oauth 2.0 - How to set the body on an apache camel http POST request -


i trying send credentials restful service takes in json formatted username , password , return access token. no matter try, 400 error , error returned server "must supply body." here's last snippet tried:

@component public class loginroute extends routebuilder {  @override public void configure() throws exception {  string jsoncredentials =  "{\"username\":\"username\",\"password\":\"password\",\"grant_type\":\"password\",\"scope\":\"admin\"}";  from("timer://login?repeatcount=1")     .setbody(constant(jsoncredentials))     .setheader(exchange.http_method, constant(org.apache.camel.component.http4.httpmethods.post))     .to("http://url");   } } 

i have confirmed credentials work fine in postman , receive proper response, access token. believe service trying connect using oauth2.

try marshalling. me worked:

// custom defined bean credentials creds = new credentials(username, password, ...); from(...).setbody(creds).marshal().json(jsonlibrary.jackson).to(... 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -