Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
igorbeslic
Contributor III

How to POST www-form-urlencoded body with talend httpService

Hi everybody!

 

Can you help me, I would like to use standard

org.talend.sdk.component.api.service.http.HttpClient

to submit POST request to an endpoint.

I see example where body in JsonObject:

https://github.com/rmannibucau/components-sample/blob/master/servicenow/src/main/java/org/talend/com...

Is there way to configure HttpClient to post www-form-urlencoded parameters in request body.

 

Thank you very much!

 

Labels (2)
1 Solution

Accepted Solutions
igorbeslic
Contributor III
Author

Yes it is... I took closer look at

org.talend.sdk.component.runtime.manager.service.http.RequestParser#parse

and concluded my method could be like this

@Codec(encoder = {XWWWFormURLEncoder.class})
	@Request(method = "POST", path = "/o/oauth2/token")
	public Response<JsonObject> getAccessToken(
		@Header("Content-Type") String contentType,
		OAuthDataStore oAuthDataStore);

where I had to add own body encoder implementation.

Fortunately Talend has good documentation and fluent lambda style code 0683p000009MACn.png so to figure out this wasn't trouble at all.

 

 

View solution in original post

1 Reply
igorbeslic
Contributor III
Author

Yes it is... I took closer look at

org.talend.sdk.component.runtime.manager.service.http.RequestParser#parse

and concluded my method could be like this

@Codec(encoder = {XWWWFormURLEncoder.class})
	@Request(method = "POST", path = "/o/oauth2/token")
	public Response<JsonObject> getAccessToken(
		@Header("Content-Type") String contentType,
		OAuthDataStore oAuthDataStore);

where I had to add own body encoder implementation.

Fortunately Talend has good documentation and fluent lambda style code 0683p000009MACn.png so to figure out this wasn't trouble at all.