Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body of Http Post #45

Open
nizarelouaer opened this issue Jan 22, 2020 · 8 comments
Open

Body of Http Post #45

nizarelouaer opened this issue Jan 22, 2020 · 8 comments

Comments

@nizarelouaer
Copy link

Hello,
I am using the http worker to communicate with my Rest Microservices. One of my services accepts a POST request with a JSON body. I tried to set the body cariables in the headers using the zeebe modeler but it does not work. In the modeler there is no option to set Variables, the only options are Variable Mappings and Headers. How can I set the body of my request using the modeler ?
Thank you

@saig0
Copy link
Contributor

saig0 commented Jan 23, 2020

Hi @nizarelouaer,

you have different options to set the body of the request.

If the body is static then you can define a custom header body on the service task (e.g. body : {"x":1}).

Otherwise, the body can be passed as a workflow instance variable with the name body. If the workflow instance doesn't have such a variable with the name then you can define an input mapping on the service task to map an existing variable in, for example, source: x.y -> target: body.

Does this help you?

@nizarelouaer
Copy link
Author

Hi @saig0 thank you for the comment. The body is not static so I’m my input mappings I am setting it like the following :
Input : variable1 output body.variable1
Input : variable2 output body.variable2
When I open my workflow instance using the operate I can set that there is a body variable body = {variable1:value1, variable2:valie2}. That is ok but my service is returning bad request, it seems that the body is not sent. I am trying to debug and see what is the problem exactly

@nizarelouaer
Copy link
Author

I am now able to set the body, but I am having an issue with the header. In my request I have a key in the header:
""""
Connection | Upgrade, HTTP2-Settings
"""
This is making the server reject the request with 400 Bad Request. Is it a key added by the http worker ? zeebe ? thank you
-- | --

@salaboy
Copy link

salaboy commented Jan 23, 2020

@nizarelouaer that is interesting.. that is probably the case.. let's investigate

@salaboy
Copy link

salaboy commented Jan 23, 2020

@nizarelouaer For some reason, we are using HttpClient class, https://github.com/zeebe-io/zeebe-http-worker/blob/master/src/main/java/io/zeebe/http/HttpJobHandler.java#L55 that might be automatically initialized with that... I will look deeper

@nizarelouaer
Copy link
Author

@salaboy I just read the http worker java code and there is nothing that sets the connection key header. I guess it is set in the zeeebe itself maybe

@nizarelouaer
Copy link
Author

nizarelouaer commented Jan 23, 2020

@salaboy in the java code the header are set without any connection key. I think that I will add the header key
“”””
Connection=keep-alive” in the java code :
final HttpRequest.Builder builder =
HttpRequest.newBuilder()
.header(“Connection”, “keep-alive”)
“””””
And compile to see if it solves the issue

@salaboy
Copy link

salaboy commented Jan 23, 2020

@nizarelouaer awesome! lets us know how it goes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants