How do I display the result of a SendHTTRequest Activity? - workflow

I have a SendHTTPRequest activity in an Elsa Workflow and it executes correctly, but the response doesn't get displayed even though I selected Read Content. The page is still empty. Why isn't it showing the result?

There isn't any documentation on SendHTTPRequest but after looking at the source code and some trial and error, I was able to get the response to show by adding a WriteHTTPResponse after the SendHTTPRequest. The SendHTTPRequest also needed some additional configuration:
Add values in the Supported Status Codes section. This creates the different flow paths after execution.
Give it a Name (e.g. GetHTTP) so you can get access to the response in WriteHTTPResponse.
Now drag the status code path to WriteHTTPRequest so it will execute that activity on a 200. In the Content section you can then use an expression to output the response.
E.g. GetHTTP.Response.Content and select JavaScript from the dropdown.

Related

Defining a new variable in order to make a huge iteration giving me an error

I have an endpoint, you can have informaciĆ³n about products
{{URL_API}}/products/
If i perform a GET method over that endpoint i will obtain the information of every product
BUT i can also specify the product that i want to know about, i.e:
{{URL_API}}/products/9345TERFER (the last code is the id of the product, called SKU)
The problem is that if i want to make a CSV in order to update the information of different products i have to define a variable called sku in the endpoint so i will be able to pass the corresponding SKU
I want to create the variable {{sku}} but i do not understand how to do that.. i tried so many times and i failed, i've searched a lot but i do not really understand
Also, should i use ":" before the declaration of the variable? i mean:
{{URL_API}}/products/:{{sku}}
or simply:
{{URL_API}}/ns/products/{{sku}}
Can you help me?
I'm super lost :(
EDIT:
I want to perform a PUT method, i want to pass different values to the body and then.. send the request (it throws an error: 404 not found)
This is what i did:
PUT|{{URL_API}}/products/{{sku}}
body:
{
"tax_percentage":"{{tax_percentage}}",
"store_code":"{{store_code}}",
"markup_top":"{{markup_top}}",
"status":"{{status}}",
"group_prices": [
{
"group":"{{class_a}}",
"price":"{{price_a}}",
"website":"{{website_a}}"
}
]
}
CSV:
POSTMAN:
Your issue seems to be just a basic understanding of how data files work with variables in Postman, here's a simple example that will work the same way for you too.
This is a basic request I'm using to resolve the variable from the data file - It's a GET request but that doesn't matter as all we're look at here is using a data file to resolve variables. All you need to do is ensure the URL is correct and that you SAVE the request before using the runner.
Here's a simple CSV file created in a text editor. The heading sku in the name on the variable it will reference inside the Postman request. Each value under that is the value that will be used for each iteration.
In the Runner, select your Collection from the list (If you have more than one) then select the CSV file. Once imported, you will be able to see a preview of the data.
If that's correct, press the Run button. The Runner will then iterate through the file and pick up the sku value in the CSV file and use it in the request. I've expanded one of the requests so you can see that the value was used in the request.

Why doesn't elapsed_time() work from log_message() even if called from post_system hook?

If I try to log benchmark->elapsed_time() in post_system hook, it just logs {elapsed_time} as if I called it from a controller.
CodeIgniter documentation says:
"post_system Called after the final rendered page is sent to the browser, at the end of system execution after the finalized data is sent to the browser."
It also says you are supposed to echo the elapsed_time() in a view to show it to the user, but... how is it possible that elapsed_time() is still being calculated after sending the finalized data to the browser?
I feel being lied to.
People keep saying I should use my own marks and get the difference, but that's not the same as using this...
Turns out the documentation also says:
"If the first parameter is empty this function instead returns the {elapsed_time} pseudo-variable. This permits the full system execution time to be shown in a template. The output class will swap the real value for this variable."
I went to the Output class and found the 2 marks it is using: total_execution_time_start and total_execution_time_end and I can use those in the post_system hook.

Obtaining transition properties in TALES expression

I've created a custom workflow in Plone, using Products.DCWorkflow. I've set the transition descriptions to a more verbose description of what just occurred and am trying to display them in a status message. I thought I would be able to do this using workflow variables, but I'm hitting what appears to be a permissions issue and don't understand why.
I've based my workflow on simple_publication_workflow, which provides a set of variables. I tried copying the approach used for the action variable, which has a default expression of transition/getId|nothing. I created an action_description variable, and added transition/description|nothing. With this, I get a None value returned. Without the |nothing option, the page redirects to https, indicating the user doesn't have the permissions required for a current action.
I've put a breakpoint into createExprContext in Products/DCWorkflow/Expression.py, and as the same user I can see the information I want in sci.transition.description. So I tried replacing the previous default expression with python:transition.description, but I get the same apparent permission problem.
I'm wondering why this is happening? Why is transition/getId a valid expression for a workflow variable, while transition/description is not?

Problems with GitHub rendering my README.rst incorrectly..?

I've got a GitHub repo/branch where I'm attempting to update the README.rst, but it's not formatting the way I expect when it comes to the bullet lists I'm including.
Everything seems ok except for my Usage section, in which I have the following:
*****
Usage
*****
- Open the template file that corresponds to the API call you'd like to make.
* Example: If we want to make a call to the RefundTransaction API we open up /templates/RefundTransaction.php
- You may leave the file here, or save this file to the location on your web server where you'd like this call to be made.
* I like to save the files to a separate location and keep the ones included with the library as empty templates.
* Note that you can also copy/paste the template code into your own file(s).
- Each template file includes PHP arrays for every parameter available to that particular API. Simply fill in the array parameters with your own dynamic (or static) data. This data may come from:
* Session Variables
* General Variables
* Database Recordsets
* Static Values
* Etc.
- When you run the file you will get a $PayPalResult array that consists of all the response parameters from PayPal, original request parameters sent to PayPal, and raw request/response info for troubleshooting.
* You may refer to the `PayPal API Reference Guide <https://developer.paypal.com/webapps/developer/docs/classic/api/>`_ for details about what response parameters you can expect to get back from any successful API request.
+ Example: When working with RefundTransaction, I can see that PayPal will return a REFUNDTRANSACTIONID, FEEREFUNDAMT, etc. As such, I know that those values will be included in $PayPalResult['REFUNDTRANSACTIONID'] and $PayPalResult['FEEREFUNDAMT'] respectively.
- If errors occur they will be available in $PayPalResult['ERRORS']
You may refer to this `overview video <http://www.angelleye.com/overview-of-php-class-library-for-paypal/>`_ of how to use the library,
and there are also samples provided in the /samples directory as well as blank templates ready to use under /templates.
You may `contact me directly <http://www.angelleye.com/contact-us/>`_ if you need additional help getting started. I offer 30 min of free training for using this library,
which is generally plenty to get you up-and-running.
For some reason, though, when you look at that on GitHub the first line of the bullet lists is coming up bold and italics and I have no idea why. Also, the sub-list where it shows Session Variables, General Variables, etc. is supposed to be all the same sub-list. I'm not sure why it's dropping into another sub when it sees General Variables.
Any information on what I've done wrong here would be greatly appreciated. Thanks!
Switch from .rst to .md and then use '#' for your headings.
## Usage
- Open the template file that corresponds to the API call you'd like to make.
* Example

appending a form parameter to url in code igniter

I have tried my best to search for an existing question with smiliar issue but was not able to find one. Here's my situation
I have a controller named search which accepts a parameter "search term", when this controller is called directly from URL like www.xyz.com/search/red+car it returns results and the URL in browser address bar is www.xyz.com/search/red+car but when the user submits the search from a from in webpage with same term, the results are coming fine but the URL does not reflect the search term.
If I do a redirect the form POST data is lost, although resubmitting the POSt is not a solution in my case either. I need a way to change the URL so that it shows the search term.
Thanks in advance for your help, please be gentle as this is my first question.
#Vlakarados - I am trying to use same controller to provide search results from post data and controller parameter. Both work fine but when using search form on webpage the search parameter is not reflected in URL.
#Rakesh Shetty - The actual method is very long, but here is the compressed format
build query as per post data and passed parameter.
populate view with results
render the view
Thanks everyone for suggesting various solution.
I used jquery to change the form action parameter, now when ever the dropdown selection is changed the value is appended to the action parameter. I also took out the dropdown from being part of post data.
There are 2 dropdowns one for area and other for zip code. This new approach works with bot dropdowns and my exsting code of controller works without any major change.
I used the following javascript code to create new action parameter when ever user changes the area. Same goes for ZIP code.
$("#cityname").change(function(){
var action = $(this).val();
alert(action);
$("#searchform").attr("action", "search/" + action);
});
I think I was not able to clearly explain my situation otherwise you people would have suggested this long ago.
The better way to do it is in your controller:
function search($search_query) {
// .. use your query as you normally would - display products, posts, messages
$data = array('search_query' => $search_query);
$this->load->view('search', $data);
}
// use this method as the form action
function search_proxy() {
$search_query = $this->input->post('search');
// if needed urlencode or other search query manipulation
redirect('controller/search/'.$search_query);
}
This way you will have no problems and will only work with data in your url.
Edit: The second option is yo use JavaScript - when user submit's the form, change the form's action to include the searched query in form action