Setting http get command as source in SpringXD - json

This command executed in SpringXD shell
http get --target https://webserviceaddress
gives me JSON document.
Is anybody has idea how to create stream with this as source ?
I see way to make just custom module, but maybe I missed somehow simpler solution ...

The http "command" is a convenience command in the XD shell, so that you don't have to use curl or any external command. It just makes a one-off http request to some endpoint (the default address being http://localhost:9000 which happens to be where the http source module would listen -- again, this is for convenience).
If you want to create a stream, then you need a module that is able to make http requests to a remote endpoint. The http-client processor module does just that. It needs to be triggered by some external source, e.g. the trigger module.
See http://docs.spring.io/spring-xd/docs/current-SNAPSHOT/reference/html/#http-client

To use webservice with get method as source I need trigger as source and http-client as following module for example below stream will get content from webservice every 60 seconds and write it to file
stream create --name stream_name --definition "trigger --fixedDelay=60 | http-client --url='''https://webservice.url''' --httpMethod=GET | file" --deploy

Related

Jmeter - when there are number of threads are running, the variable from JSON extractor is not working sometimes

I am now using Jmeter to run the test of APIs.
The situation is that I have a login Api which will return a token inside response. I use a JSON extractor to save the token as a variable. Then, I use the ${token} is the header of other requests.
However, I found that when I was trying to run 40-50 threads, the ${token} in some threads would be empty, and caused a high error rate.
Therefore, may I ask is there any method to solve it and why?
Thanks very much.
Try saving full response from the Login API, most probably your server gets overloaded and cannot return the token and returning some error message instead.
There are following options:
If you're running JMeter in command-line non-GUI mode you can amend JMeter's Results File Configuration to store the results in XML form and include the response data, add the next lines to user.properties file:
jmeter.save.saveservice.output_format=xml
jmeter.save.saveservice.response_data=true
and when you run your test next time the .jtl results file will contain response bodies for all the requests.
Another option is using a Listener like Simple Data Writer configured like:
and when you run the test the responses.xml file will contain the response data
Both .jtl results file and responses.xml can be inspected using View Results Tree listener
More information: How to Save Response Data in JMeter

JMeter to test java rest Api

How can i pass the json for post method if my json is like:
{
"REQUEST":{"REQUEST_BODY":{"Account_Name":"ak"}}
}
It gives me an error at time of parsing json value
In postman it run properly
In HTTP Request use Body Data tab and of course fill-in Server Name, Port Number, Path and Update Method if needed:
And under HTTP Request add a Header Manager:
And add to it required headers:
Note Content-type might be different for you.
If your request works in Postman you can just record it in JMeter:
Configure JMeter for recording, the fastest way is using JMeter Templates feature
From JMeter's main menu choose File - Templates - Recording - Create
Expand Workbench - HTTP(S) Test Script Recorder and click "Start
Configure Postman for recording. You can "tell" Postman which proxy server to use (JMeter in your case) via --proxy-server command-line argument
C:\Users\your_user_name\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
Execute your request in Postman
JMeter will capture the request and store it under Test Plan - Thread Group - Recording Controller
References:
Apache JMeter proxy Step-by-step
How to configure Postman Native Client App to use an external proxy

Special character in JSON payload not processed successfully when running the script in JMeter

When trying to process the JSON Message contains special character " ®"
which is actually a registered trademark symbol, failed with error when trying in JMeter. The same payload is working as expected in other tools like postman etc. Please advise on how to fix this issue in JMeter.
Error:
{
"code": 400,
"errors": [
{
"key": "messages",
"message": "Unable to translate bytes [AE] at index 901 from specified code page to Unicode."
}
]
}
Thanks
Bharath
I cannot reproduce your issue, most probably something is wrong with your JMeter Configuration, i.e. try setting file.encoding and client.encoding.override JVM System Properties to UTF-8
You can set aforementioned properties in system.properties file (located in JMeter's "bin" folder), JMeter restart will be required to pick the properties up.
Also given you can execute the same request using Postman you can just record it with JMeter's HTTP(S) Test Script Recorder.
Configure JMeter for recording using JMeter Templates feature (from JMeter's main menu choose File -> Templates -> Recording -> Create and start the HTTP(S) Test Script Recorder
Configure Postman for recording. In order to set it for using JMeter as a proxy launch it with --proxy-server option like:
C:\Users\your_user_name_here\AppData\Local\Postman\app-x.x.x\Postman.exe --proxy-server=localhost:8888
See How to configure Postman Native Client App to use an external proxy for more information.

HTTP request error from running Postman Collection tests with Newman?

I've been using the new commandline for Postman, Newman, and have been attempting to run Collection tests that work fine when I pass them through the packaged app Jetpacks add-on, but do not run properly in the commandline. Although the json Collection file that I am passing does contain the proper header declarations, I don't have any other clues at this point, so I suspect that this may be an HTTP header issue. But I am not sure exactly what is wrong, as I am rather new to using Postman.
The tests that I'm trying to run are on some calls to an ASP.Net web API, very simple server response-checking one-line javascript tests like the ones in this tutorial.
A sample line that I enter into the console:
$ newman -c collectionfile.json -e environmentfile.json -n 5
achieves such a result:
RequestError: [token] terminated. Error: undefined
Any suggestions/help would be appreciated.
I ran into this problem as well and spent quite a few hours trying to figure it out. Eventually I realized that an address such as "www.google.com" will work in the chrome plugin UI, but not in Newman. For it to work in Newman, the address must be "https://www.google.com". Also, make sure that you have your data file (if you are using variables like {{url}}) set up correctly. You can use "-d dataFile.json" to define a data file. More information on that here.

How can I get the json object which represents a Yahoo! pipe

It seems that Yahoo pipes are represented using JSON. I want to download these JSON objects for some research purpose. Usually a Yahoo pipe is rendered in a browser editor thru a url like this: http://pipes.yahoo.com/pipes/pipe.edit?_id=XgRo96h13BGtJWvS8SvLAg, but you can't get the corresponding JSON object to this Yahoo pipe. Does anyone know how to get JSON objects representing Yahoo pipes and store them in any persistent form?
It is possible to get hold of a JSON description of a Yahoo Pipe using a URL of the form:
http://pipes.yahoo.com/pipes/pipe.info?_out=json&_id=PIPE_ID
The pipe2py python library demonstrates how to grab the JSON description of a pipe and "compile" it to a Python equivalent that can be run on your own server.
The post Exporting Yahoo Pipe Definitions, Compiling Them to Python, and Running Them in Scraperwiki describes how you can use pipe2py in the Scraperwiki environment to compile and execute pipes on Scraperwiki using pipe definitions imported directly from Yahoo Pipes, or exported from Yahoo Pipes and then stored locally in a Scraperwiki database table.
When I load that page in a browser I can see that it makes an ajax request for:
http://pipes.yahoo.com/pipes/ajax.pipe.load?id=XgRo96h13BGtJWvS8SvLAg&_out=json&modinfo=true&rnd=7560&.crumb=MjvGjpzhPLl
That's your object but I'm not sure if I'm answering your question of how to "get it". If you need to get it through a program you would need a script that loges into pipes and extracts that url.
A quick way, while not automated, is to use an HTTP analyzer. Here's a process for getting the object using HttpFox (I use v0.8.9) for Firefox. With the analyzer running, load the edit page for a pipe, like the one you linked:
http://pipes.yahoo.com/pipes/pipe.edit?_id=XgRo96h13BGtJWvS8SvLAg
Look at the request with a URL that starts with:
http://pipes.yahoo.com/pipes/ajax.pipe.load?id=....
Next, explore the content of the request (there's a 'Content' tab in HttpFox). That's the JSON object representing the pipe structure.
Use pipe.run?[your pipe id here]&_render=json as opposed to pipe.edit
So in your case to get the json it would be - http://pipes.yahoo.com/pipes/pipe.run?_id=XgRo96h13BGtJWvS8SvLAg&_render=json
I guess how you implement the client is dependent on what you like writing in/what other functionality you need.
You could also do it the other way around and use the web service service module to post the data to a script that can extract the json and persist it to a database. You could check out json.org.