Hi,
I’m wondering how to make a HTTP Request “dynamic”, with POST or PATCH behaviour.
I define the request method with a variable, like the URL.
But, the HTTP Request node don’t really know it could only be a POST or PATCH request.
So, only the Headers / Query params are displayed.
Same if JSON/Raw Parameters are enabled (that sounds consistent )
Could we let the user define what exactly he want to send ?
Does it sounds okay for you ?
Thanks for your answer
jan
October 11, 2020, 10:06pm
2
That will not work because depending on the selected method different parameters will be displayed.
So if you want to do something like that, you have to use an IF or Switch Node and then direct to different HTTP Request Nodes.
mdartic
October 12, 2020, 12:39pm
3
Thanks for your quick answer, again !
I tested with an IF, but I’m stucked cause the IF don’t pass always in both true / false branches.
I used a merge after, but it’s not trigerred when one of the both branches is not used.
I hack by coding directly in a Function node.
If you know how to do with a Merge by the way, I’m curious (if my explanations are enough understandable).
jan
October 12, 2020, 3:16pm
4
Yes, I think I know what you mean. That in the case the IF-Node does not output anything on true the Merge-Node will not execute at all.
What you can do here is to set “Always Ouput Data” on the IF-Node and then filer out the empty items after the merge.
Here an example workflow:
Sorry to reopen/hijack the topic, but I have the exact same usecase as @mdartic . When I try the solution you mentioned @jan , there’s always a POST and PATCH request executed, even when there is nothing to PATCH/POST. This results in creating an empty item in the API. In the below example there are two existing items that should be patched, but the POST is also executed with an empty item. I can filter it out afterwards like you suggested, but the POST should not even be executed. How can I solve this?
Welcome to the community @jan
Just remove the merge node from the example you sent and connect the POST and PATCH to the function node or the node you need.
Thanks for the answer @RicardoE105 ! If I try that, the function node will be executed twice, but I need all items (after POST/PATCH) in one execution.
Ahh, gotcha. Then use an IF node to filter out the empty values. Check the example workflow below.
That’s exaclty what I tried yes, but then the POST is exectued while it shouldn’t. Resulting in empty API-requests.
Ahh, interesting. After some thinking came up with the example below. That should do it.
Thanks, that does the trick indeed. Interesting approach!
Great it worked. Have fun.