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

How can I send an http post request with properties, in the body or in headers? #2149

Closed
MunozVictor opened this issue Mar 2, 2020 · 15 comments
Labels
Type: Question Further information is requested

Comments

@MunozVictor
Copy link
Contributor

Describe the bug

How can I send an http post request with properties, in the body or in headers?

I don't know what the correct syntax is to be able to send properties in the "Send Http request". or if it is possible or not, since when I put the properties in the body the json validator does not pass and in headers it returns an error. Is it possible to remove the json validator to allow the reference of properties?

Version

Browser

  • Chrome

OS

  • Windows

To Reproduce

Steps to reproduce the behavior:

  1. Create a property
  2. Set it with some value.
  3. Try to reference that property from "Send http request" from the body or headers

Expected behavior

Screenshots

Captura

Additional context

@MunozVictor MunozVictor added the Needs-triage A new issue that require triage label Mar 2, 2020
@MunozVictor
Copy link
Contributor Author

MunozVictor commented Mar 2, 2020

This is an alternative solution because it only works through query string parameters, but it does not work with properties in the body or headers @hibrenda

@cwhitten
Copy link
Member

cwhitten commented Mar 2, 2020

hi @MunozVictor can you share the exact shape of the body you expect to use?

@cwhitten cwhitten added Type: Question Further information is requested and removed Needs-triage A new issue that require triage labels Mar 2, 2020
@MunozVictor
Copy link
Contributor Author

It's in the picture @cwhitten . The problem is not in my json , the problem is that you cannot put a reference to a property in the body. I rewrite my question, How can I send an http post request with a body builded dynamically?

It's indifferent if is this :
{"username": @{user.property} }

or this :

@{user.property}

Because my property can be an a json. The problem is the validator to json and syntax to reference to the properties inside the body and headers

@luhan2017
Copy link
Contributor

@MunozVictor, could we know which composer version are your using? Previously we are using this format to form a HttpBody:
"username": {user.property} }
After the recent update in master branch, now you can form a HttpBody like this:
"username": ${user.property} }

Please try that and let me know if it works.

@MunozVictor

This comment has been minimized.

@luhan2017
Copy link
Contributor

@MunozVictor oh, I am really sorry, I missed the quotes in my reply.
could you try this:
{"username": "${user.property}" }

@MunozVictor
Copy link
Contributor Author

@MunozVictor oh, I am really sorry, I missed the quotes in my reply.
could you try this:
{"username": "${user.property}" }

Works! Thanks @luhan2017

@MunozVictor
Copy link
Contributor Author

@MunozVictor oh, I am really sorry, I missed the quotes in my reply.
could you try this:
{"username": "${user.property}" }

Works! Thanks @luhan2017

Hi @luhan2017 , How can I send a integer ?, because your solution it's only valid for send strings

@MunozVictor MunozVictor reopened this Mar 13, 2020
@cwhitten
Copy link
Member

@BarisCoruh
Copy link

Hello, I am getting a bad request error after this request. Where do you think I'm making a mistake?

error2

@luhan2017
Copy link
Contributor

@Barisc I think this is because it is a GET request, and you want to POST the body. Could you please try to update the GET to POST?

@BarisCoruh
Copy link

BarisCoruh commented Dec 9, 2020 via email

@BarisCoruh
Copy link

BarisCoruh commented Dec 9, 2020 via email

@aForero-GitHub
Copy link

Hi, if you still need a hand with this, here is what worked for me.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question Further information is requested
Projects
None yet
Development

No branches or pull requests

6 participants