API Timezone Parameter ignored by CURL - api

I have a Problem with the URL-Encoded Timezone parameter (Europe%2FBerlin) in an API request:
My API Request to get a data feed from thingspeak:
https://api.thingspeak.com/channels/CHANNELID/feed.csv?api_key=APIKEY&timezone=Europe%2FBerlin
If I post this into the Browser the Timezone Parameter is recognised and displayed correctly.
If I put the request into a curl command like this:
curl -o /Path/To/File.csv https://api.thingspeak.com/channels/CHANNELID/feed.csv?api_key=APIKEY&timezone=Europe%2FBerlin
... the timezone parameter is ignored.
How can this be fixed?

By quoting the URL. Put it within double quotes.
The '&'-symbol is treated special by the shell and is used to put the command in the background and then treat what's on the right side of it as a second, separate command.

Related

Postman Path Variables without slashs

I have a basic GET request with a CustomerName path variable that I am trying to access in Postman like so:
https://my-domain.com/../{{version}}/{{tenant}}/{{company}}/AR/ARCustomers(":CustomerName")
For some reason the : doesn't get recognized as a PATH variable without a / or \ in front of it like so /:. Additionally the path variable will be seen as CustomerName") unless I escape the ". If I was to enter this the way I think it expects then I would end up with ARCustomers("/:CustomerName/") but unfortunately when I do that it gets translated in the curl like so ARCustomers("/TEST/")' (adding the unnecessary /s).
How do I set a path variable without the forward slashes, is this not possible?
Additionally in this example I'm using " around my path variable but I actually need it to be ', unfortunately that two is causing issues with forward slashes in my cURL
if your url is like :
https://my-domain.com/AR/ARCustomers("/:CustomerName/")
Then in pre-request script use:
path = pm.request.toJSON().url.variable.find((a)=>a.key==="CustomerName").value
console.log(pm.request.url.toString())
pm.request.url=pm.request.url.toString().replace(`/${path}/`,path)
console.log(pm.request.url.toString())
Postman properties are exposed through pm object and you can modify most properties except body from prerequest script.
Here we are replacing /content/ with content

Jmeter dynamic URL property with variable not substituted

I have a simple Jmeter test where I have a property to set the URL. The PATH in the Jmeter test is set to the following.
${__P(GET_URL,)}
This works well for all URLs that I have been working with, except for the ones where I need to pass a variable in the URL component.
For example, it works for http://server:port/getemployeelist when I run the test with -JGET_URL=/getemployeelist
Then I created a CSV config element to populate the variable EMP_ID.
Then if I run the test with -JGET_URL=/getemployee/${EMP_ID}, the EMP_ID variable is not getting substituted. Jmeter test gives me an error as follows:
java.net.URISyntaxException: Illegal character in path at index xx: https://://getemployee/${EMP_ID}
Appreciate any help/pointers.
It will not work this way, JMeter doesn't know anything about ${EMP_ID} at the time it is being started, you need to append this ${EMP_ID} to HTTP Request sampler "Path" in the runtime
Start JMeter as:
jmeter -JGET_URL=/getemployee/
Use CSV Data Set Config to read the EMP_ID from the CSV File
In the HTTP Request sampler use construction like /${__P(GET_URL,)}/${EMP_ID} to combine JMeter Property specified via -J command line argument and JMeter Variable originating from the CSV file.
If anything goes wrong first of all check jmeter.log file - it normally contains enough troubleshooting information. If there is nothing suspicious - use Debug Sampler and View Results Tree listener combination to inspect requests and response details, variables and properties names and values, etc.
Had asked this question a while back. Thought of posting the solution which I eventually ended up implementing. In the solution, I created a template jmx with a substitution variable for the HttpSampler.path and then replace the path at runtime. Following are the key points from the scripting done.
This turned out to be a simpler solution that worked for all kinds of API call patterns.
Created a template jmx (jmeter_test_template) with the following line.
<stringProp name="HTTPSampler.path">#PATH#</stringProp>
This jmx has CSV config element to populate variable "EMP_ID". To create this file, just create a new test with any URL and then save it as a template and replace the URL with substitution variable #PATH#.
Created a wrapper script like run_any_api.sh with usage,
sh run_any_api.sh URL=http://server:port/myapp/employees/${EMP_ID}
In the wrapper script, this URL is replaced in place of the token.
sed "s/#PATH#/$URL" jmeter_test_template.jmx > jmeter_test_template.current_test.jmx
jmeter -t jmeter_test_template.current_test.jmx
Last but not the least, please remember to cleanup the temporary jmx,
rm jmeter_test_template.current_test.jmx

SoapUI Auth Header with special characters

I am using SoapUI and encountered that if I add umlauts into the password, it does not work as expected.
Here is an example: Lets assume as username "täst" and as password "!23Öüok". SoapUI will create the following Base64 encoded String: "Authorization: Basic dD9zdDohMjM/P29r[\r][\n]". Decoding "dD9zdDohMjM/P29r" will result into this "t?st:!23??ok".
Is there any SoapUI specific setting or anything that I am missing? I think the Base64 encoded String should be like this: "dMOkc3Q6ITIzw5bDvG9r"
I believe that you need to have have encoding as UTF-8 in order to see the desired value.
Go to SOAPUI_HOME/bin
Have a backup of soapui.bat file
Close soapui tool if it is running
Open soapui.bat in a text editor of your choice
Find line set JAVA_OPTS=%JAVA_OPTS% -Dsoapui.ext.libraries="%SOAPUI_HOME%ext"
Add below line after the above line
set JAVA_OPTS=%JAVA_OPTS% -Dfile.encoding=UTF-8
Save the file
Restart soapui, make sure that is reflected in System Properties
This should help you to see the desired output.
Note that if you are using testrunner.bat to execute the tests, incorporate the above suggested change into this file as well.

cronjob not working, but working in browser

So I have this weird behaviour:
A customers runs an oxid-shop. He bought a module and in its documentation, it stated:
Add 3 cronjobs: < url >
So, nothing too special so far. I tried it in the browser and everything worked fine. My output was:
Convert complete! 0 articles. File: google.xml
So the Script seems to work. Then I tried to combine it with a cronjob.
*/02 * * * * curl http://www.example.org/index.php?cl=param1&fnc=param2&rto=param3
as you can tell, a complete valid url (no special chars or something like this in the vars)
However, the output is the following:
Warning: Smarty error: unable to read resource: "" in /usr/www/users/.../www2/core/smarty/Smarty.class.php on line 1094
I also tried it with lynx -dump URL. Same output. I can't modify the script, since it is encrypted.
Any idea what I could try? Might the be due to the params?
Tried it on 2 different servers with the same outcome.
The problem could in deed be that there are parameters in your URL.
When using [] or {} sequences when invoked from a command line prompt,
you probably have to put the full URL within double quotes to avoid
the shell from interfering with it. This also goes for other
characters treated special, like for example '&', '?' and '*'.
Source: https://curl.haxx.se/docs/manpage.html
So you should try to enclose your URL with double quotes.

How do I add a heroku deployhook:email using API?

I have been able to add a deployhook (for email and IRC) using the heroku cli (sdk). I would like to be able to add or update the email values (receipient etc) using the API. Is this possible? When I try to curl request to add a hook I get an error message noting the need for extra data: receipient, body, etc.
You can find a bit more detail about the different arguments here: https://devcenter.heroku.com/articles/deploy-hooks#email
Once you know what values you want/need you should be able to send it using this:
curl -n -g -X POST 'https://api.heroku.com/apps/MYAPP/addons/deployhooks%3Aemail?config[recipient]=me#example.com&config[subject]="MYAPP%20Deployed"&config[body]="{{user}}%20deployed%20app"'
The arguments:
-n reads credentials from netrc (this should be set by the toolbelt/cli)
-g tells it to not try and interpret the [] and {} in the url
-X POST sets it to be a POST rather than get request
Beyond that it was just a matter of encoding the params properly. I believe of those values recipient is the only required value (and the others have reasonable defaults).
You can only have one deployhook per type and they don't appear to allow updates. So if you need to change it, you'll want to remove the old one and then add another with the updated attributes. You can remove the old one like this:
curl -n -X DELETE 'https://api.heroku.com/apps/MYAPP/addons/deployhooks%3Aemail'