CURL command to API call from AWS EC-2 server: Japanese data getting garbled in DB - shell

I am trying to use CURL command to API call from AWS EC-2 server for our one application. I am using below request:
result1=`curl "https://localhost:15443/statusapi/admintool/insertOutage"
-H "cookie: JSESSIONID=5C06D8608D18AF2B87C5ADBCD4E206BF; XSRF-TOKEN=$x_csrf_token"
-H "origin: https://localhost:15443"
-H "accept-encoding: gzip, deflate, br"
-H "x-csrf-token: $x_csrf_token"
-H "authorization: Bearer $XSRF_TOKEN"
-H "content-type: application/json;charset=UTF-8"
-H "accept: application/json, text/plain, */*"
-H "authority: status.vizitechsolutions.com:15443"
-H "user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.75 Safari/537.36"
--data-binary "[{\"serviceTypeEn\":\"dummy_service\",
\"serviceNameList\":\"VeriTrans 3G,\",
\"startTime\":\"1532684645737\",
\"startStatusEn\":\"Down\",
\"startStatusJp\":\"ダウン\",
\"startMessageEn\":\"Cannot process transaction due to outage at dummy service.\",
\"startMessageJp\":\"ダミ<81>[サ<81>[ビス<8f>瘧Qのためエラ<81>[となる事<8f>ロが発<90>カしております<81>B ダウン\",
\"locationEn\":\"dummy_location\",
\"locationJp\":\"ダミ<81>[<8f>・8f>浬",
\"rank\":\"-\",
\"createdBy\":\"lp\",
\"createdOn\":\"1532676990290\"}]"
--compressed --insecure -vvv`
English Field data is stored in DB properly, but Japanese data getting garbled in DB. When we try same through web application data get stored properly for both English and Japanese.

Related

How to filter ChromeDevTools cURL correctly for Windows CMD?

I am trying to check if I can access a page the same way in cURL as I can access it in Chrome.
With ChromeDevTools you can copy the request as a cURL command depending upon your OS.
So I selected Windows(cmd), which gave me roughly this command:
curl "https://practice.org/tracks/DSA/?batch=339" ^
-H "authority: practice.geeksforgeeks.org" ^
-H "cache-control: max-age=0" ^
-H "sec-ch-ua: ^\^" Not;A Brand^\^";v=^\^"99^\^", ^\^"Google Chrome^\^";v=^\^"91^\^", ^\^"Chromium^\^";v=^\^"91^\^"" ^
-H "sec-ch-ua-mobile: ?0" ^
-H "upgrade-insecure-requests: 1" ^
-H "user-agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36" ^
-H "accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9" ^
-H "sec-fetch-site: none" ^
-H "sec-fetch-mode: navigate" ^
-H "sec-fetch-user: ?1" ^
-H "sec-fetch-dest: document" ^
-H "accept-language: en-US,en;q=0.9" ^
But when the 3rd header is encountered in Windows CMD the whole command is executed:
-H "sec-ch-ua: ^\^" Not;A Brand^\^";v=^\^"99^\^", ^\^"Google Chrome^\^";v=^\^"91^\^", ^\^"Chromium^\^";v=^\^"91^\^"" ^
When the above line is encountered the whole command is executed without waiting for more input.
The formatting is not done correctly.
I don't know much about Batch Programming in Windows, and have no way to correct the input.
Can anyone help ?

Can't send a Jmeter request with graphql, 400 response using valid URL

From what I've read on https://graphql.org/learn/serving-over-http/ and Performance test for graphQL API, I can send a graphQL request over jmeter.
In the stack overflow example, a graphQL server was built with Apollo and then queried via Jmeter. I am just trying to do load testing and not build schemas or data sets, so I don't have Apollo on my local machine, and I'm also not sure that I would be testing the QA environment if I did try to do this all locally.
I can access our graphQL at https://proprietary-website/graphql/gql and if I run the following query, it returns the expected results:
query currentUserProfile {
currentUserProfile {
id
}
}
Now, I try to apply that to jmeter
I create a HTTP Request in my thread group with protocol: https, server name: proprietary-website, method: GET, path: /graphql/gql
I create an HTTP Header Manager and include the required Bearer Token and Content-Type headers
I create a listener to View Results Tree
Then I run a jmeter load test with 500 threads
I see the valid URL passed in the request body:
GET https://proprietary-website/graphql/gql
GET data:
{"query":{"currentUserProfile {id}"}}
[no cookies]
but I get back:
HTTP/1.0 400 Bad Request
Content-Type: text/html; charset=UTF-8
Referrer-Policy: no-referrer
Content-Length: 1555
Date: Thu, 12 Dec 2019 16:40:26 GMT
I am new to graphql, am I not allowed to send Jmeter requests to the URL my dev gave me and do I have to use the apollo server? If so, can someone point me to some examples?
I am on Windows 10
I also tried:
k6, but this requires docker and i have no admin rights on my computer
easygraphql-lt but when I ran a test script with #easygraphql-lt, I got dependency errors that I don't quite understand how to fix
I looked at easygraphql-load-tester, but this would require me to have access to the project but all i have is the website. I don't have a graphQL.js or an index.js to reference
UPDATE: I just saw that I can copy the query as a curl request so I pasted that request in command line and it gave me extra headers that I put in my jmeter HTTP Header manager:
$ curl 'https://proprietary-website/graphql/gql' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: https://proprietary-website' -H 'Authorization: Bearer redacted' --data-binary '{"query":" query currentUserProfile { currentUserProfile { id }}"}'
But I still get a 400 back, so I think I need to send the query differently as it is showing appended as a --data-binary (not sure what that means). I tried some other SO suggestions, no luck so far
I also tried against an app out of the O'Reilly graphql book, snowtooth.herokuapp.com. This was simpler, so the curl request was simpler, and the information I pasted into jmeter was less, but I still got the error: GET query missing using Protocol: HTTP, server name: snowtooth.herokuapp.com, method: GET and Body Data: {"query":"query { allLifts { name}}"}, plus all the requisite headers in the Header Manager
Not sure what your proprietary website implementation is, however this http://snowtooth.herokuapp.com/ can be tested like:
HTTP GET request:
HTTP POST request:
Also be aware that since JMeter 5.1 it's possible to create a JMeter test plan from CURL command, this http://snowtooth.herokuapp.com/ gives me the following CURL command:
curl 'http://snowtooth.herokuapp.com/' -H 'Accept-Encoding: gzip, deflate, br' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Connection: keep-alive' -H 'DNT: 1' -H 'Origin: http://snowtooth.herokuapp.com' --data-binary '{"query":"{allLifts{name}}"}' --compressed
And when I import it to JMeter I can execute the requests successfully:

How do I pull some information from a website via bash?

I would like to get the specific information from this site BTC value:
foxbit.com.br
I would just like to take the value of the BTC , but with WGET and CURL can not , because the value of the page is not static .
Do this is possible?
Here's how you can go about doing such things:
Load the page and see that the values load shorly after the page. This indicates that it's updated by a separate ajax request.
Open the Chrome developer console and look through the small handful of requested xhr resources to see which document it comes from.
Right click the request and copy as cURL.
You get some monstrosity like this:
curl 'http://www.foxbit.com.br/cdn-cgi/pe/bag2?r\[\]=https%3A%2F%2Fapi.blinktrade.com%2Fapi%2Fv1%2FBRL%2Fticker%3Fcallback%3DjQuery21109214518333319575_1448214593730%26crypto_currency%3DBTC%26_%3D1448214593731' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'PE-Token: 136c4c7c7a1e6a4bea75c61a93655067d5752459-1448214593-1800' -H 'Accept-Language: en-US,en;q=0.8,no;q=0.6,nb;q=0.4' -H 'User-Agent: Mozilla/5.0 (X11; CrOS x86_64) AppleWebKit/530.00 (KHTML, like Gecko) Chrome/45.0.0.0 Safari/530.00' -H 'Accept: */*' -H 'Referer: http://www.foxbit.com.br/' -H 'Cookie: __cfduid=d069fe8cecbd20bd0d09a5c04fbc398601448214586; _gat=1; _ga=GA1.3.1862709458.1448214588' -H 'Connection: keep-alive' --compressed
However, the URL clearly indicates that it just fetches from some other API, so we decode that URL and get:
https://api.blinktrade.com/api/v1/BRL/ticker?callback=jQuery21109214518333319575_1448214593730&crypto_currency=BTC&_=1448214593731
And we can drop the parameters that seem irrelevant and see what we get now:
$ curl 'https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC'
{"high": 1272.5, "vol": 50.77552492, "buy": 1238.51, "last": 1244.0, "low": 1238.13, "pair": "BTCBRL", "sell": 1243.99, "vol_brl": 63522.33386051}
Nice clean JSON. We can now easily make a command fetching and picking out the value we're interested in with the json tool jq:
$ curl -s 'https://api.blinktrade.com/api/v1/BRL/ticker?crypto_currency=BTC' |
jq '.last'
1244

Ruby cURL POST Request not going through

I am using Paw, an application to test REST requests. I have the follow request working using the application but need to change it to use cURL to use in my ruby on rails application.
POST /rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment HTTP/1.1
Content-type: application/json
Accept: application/json
Authorization: Basic dWkud29ya2JvdDpFVmgzUFQ0dEch
Cookie: JSESSIONID=C851F60AFB4A83F12753B9CCBC745093
Host: bamboo10.com
Connection: close
User-Agent: Paw/2.2.5 (Macintosh; OS X/10.10.5) GCDHTTPRequest
Content-Length: 32
{"content":"here is a comment, for testing purposes“}
I think it should look something like this but it is not working. I did not add the real username and password (or host) in for security reasons. Any help would be much appreciated. Thank you!
`curl -X POST -u username:password --data {"body": "This is a comment, for testing purposes"} -H "Accept: application/json" -H "Content-type: application/json" https://bamboo.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment`
After a little time, I found the correct way to do it. It appears I was missing a ' before and after the data, as well as changing the json element to be content and not body
curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -u username:password -d '{"content": "This is a comment, for testing purposes"}' https://bamboo10.com/rest/api/latest/result/TRUNKDEVQAUNIT-TESTANDRGITBUILDDEV-12/comment

cURL requests blocks IP after 1 request

I have a simple terminal shell command here:
curl -v -m 60 -H 'Accept-Language: en-US,en;q=0.8,nb;q=0.6' -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3" http://imeidata.net -e http://imeidata.net/iphone/model-check http://imeidata.net/iphone/model-check?sn=C8PKTRF5DTC1
When I run it for first time I get full result (Page is about 23KB)
When I run this command for second time I get only a sample page
(about 17KB)
I am still able to visit this website, so my IP is not blocked but only cURL request are denied.
Again if I change my IP.. same will happen.
Why do my requests get blocked?
Any solution will be highly appreciated.
Thank you for helping.
I would fire it with "-k" # the end of the request.
So fire your request + " -k" like below:
curl -v -m 60 -H 'Accept-Language: en-US,en;q=0.8,nb;q=0.6' -A "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3" http://imeidata.net -e http://imeidata.net/iphone/model-check http://imeidata.net/iphone/model-check?sn=C8PKTRF5DTC1 -k

Resources