BigQuery Error JSON_EXTRACT although jsonPath is valid - json

I'm trying to extract some information out of the httparchive har tables, which are provided for free.
Trouble is that BQ returns an error on a JSON_EXTRACT() function although a number of jsonPath validators are executing it perfectly (http://jsonpath.com/ or jsonpath.curiousconcept.com/).
This is my query:
SELECT
JSON_EXTRACT(payload,"$._host")AS host,
JSON_EXTRACT(payload,"$.request.headers[?(#.name=='Referer')]")AS referer,
url,
payload
FROM
[httparchive:har.2016_01_01_chrome_requests]
LIMIT
100
expected return based on the example payload json below would be
"http://www.echosdunet.net/"
This is the error:
Error: JSONPath parse error at: [?(#.name=='Referer')]
This is an example payload json:
{
"pageref": "page_1_0",
"startedDateTime": "2016-01-03T22:18:52.632+00:00",
"time": 452,
"request": {
"method": "GET",
"url": "http://disqus.com/embed/comments/?base=default&version=f3e1717b71e7256da258d3a504e56865&f=echosdunet&t_i=node%2F19849&t_u=http%3A%2F%2Fwww.echosdunet.net%2Fnode%2F19849&t_e=Accueil&t_d=Comparatif%20et%20test%20ADSL%20et%20fibre&t_t=Accueil&s_o=default&l=fr",
"headersSize": 650,
"bodySize": -1,
"cookies": [],
"headers": [{
"name": "Host",
"value": "disqus.com"
}, {
"name": "Connection",
"value": "keep-alive"
}, {
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
}, {
"name": "Upgrade-Insecure-Requests",
"value": "1"
}, {
"name": "User-Agent",
"value": "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36 PTST/254"
}, {
"name": "Referer",
"value": "http://www.echosdunet.net/"
}, {
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
}, {
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
}],
"httpVersion": "1.1",
"queryString": [{
"name": "base",
"value": "default"
}, {
"name": "version",
"value": "f3e1717b71e7256da258d3a504e56865"
}, {
"name": "f",
"value": "echosdunet"
}, {
"name": "t_i",
"value": "node/19849"
}, {
"name": "t_u",
"value": "http://www.echosdunet.net/node/19849"
}, {
"name": "t_e",
"value": "Accueil"
}, {
"name": "t_d",
"value": "Comparatif et test ADSL et fibre"
}, {
"name": "t_t",
"value": "Accueil"
}, {
"name": "s_o",
"value": "default"
}, {
"name": "l",
"value": "fr"
}]
},
"response": {
"status": 200,
"statusText": "",
"headersSize": 1161,
"bodySize": 2017,
"headers": [{
"name": "Server",
"value": "nginx"
}, {
"name": "Content-Type",
"value": "text/html; charset=utf-8"
}, {
"name": "Content-Security-Policy",
"value": "script-src https://*.twitter.com:* https://api.adsnative.com/v1/ad.json *.adsafeprotected.com https://cas.criteo.com/delivery/0.1/napi.jsonp *.services.disqus.com:* http://referrer.disqus.com/juggler/ disqus.com http://*.twitter.com:* a.disquscdn.com https://referrer.disqus.com/juggler/ https://*.services.disqus.com:* *.moatads.com 'unsafe-eval' https://mobile.adnxs.com/mob https://ssl.google-analytics.com"
}, {
"name": "Link",
"value": "<http://a.disquscdn.com>;rel=preconnect,<http://a.disquscdn.com>;rel=dns-prefetch"
}, {
"name": "Cache-Control",
"value": "stale-if-error=3600, s-stalewhilerevalidate=3600, stale-while-revalidate=30, no-cache, must-revalidate, public, s-maxage=5"
}, {
"name": "p3p",
"value": "CP=\\DSP IDC CUR ADM DELi STP NAV COM UNI INT PHY DEM\\"
}, {
"name": "Timing-Allow-Origin",
"value": "*"
}, {
"name": "X-Content-Type-Options",
"value": "nosniff"
}, {
"name": "X-XSS-Protection",
"value": "1; mode=block"
}, {
"name": "Last-Modified",
"value": "Thu, 11 Jun 2015 13:30:36 GMT"
}, {
"name": "ETag",
"value": "W/\\lounge:view:3840102421.d93d9c4bc037078ffc811833ae267a6f.0\\"
}, {
"name": "Content-Encoding",
"value": "gzip"
}, {
"name": "Content-Length",
"value": "2017"
}, {
"name": "Accept-Ranges",
"value": "bytes"
}, {
"name": "Date",
"value": "Sun, 03 Jan 2016 22:18:51 GMT"
}, {
"name": "Age",
"value": "0"
}, {
"name": "Connection",
"value": "keep-alive"
}, {
"name": "Vary",
"value": "Accept-Encoding"
}],
"httpVersion": "1.1",
"redirectURL": "",
"content": {
"size": 2017,
"mimeType": "text/html"
},
"cookies": []
},
"cache": {},
"timings": {
"blocked": -1,
"dns": 202,
"connect": 32,
"ssl": -1,
"send": 0,
"wait": 108,
"receive": 110
},
"_ip_addr": "104.156.81.134",
"_method": "GET",
"_host": "disqus.com",
"_url": "/embed/comments/?base=default&version=f3e1717b71e7256da258d3a504e56865&f=echosdunet&t_i=node%2F19849&t_u=http%3A%2F%2Fwww.echosdunet.net%2Fnode%2F19849&t_e=Accueil&t_d=Comparatif%20et%20test%20ADSL%20et%20fibre&t_t=Accueil&s_o=default&l=fr",
"_responseCode": "200",
"_load_ms": "218",
"_ttfb_ms": "108",
"_load_start": "2632",
"_bytesOut": "652",
"_bytesIn": "3180",
"_objectSize": "2017",
"_cacheControl": "stale-if-error=3600, s-stalewhilerevalidate=3600, stale-while-revalidate=30, no-cache, must-revalidate, public, s-maxage=5",
"_contentType": "text/html",
"_contentEncoding": "gzip",
"_type": "3",
"_socket": "153",
"_score_cache": "-1",
"_score_cdn": "-1",
"_score_gzip": "100",
"_score_cookies": "-1",
"_score_keep-alive": "100",
"_score_minify": "-1",
"_score_combine": "-1",
"_score_compress": "-1",
"_score_etags": "-1",
"_is_secure": "0",
"_dns_ms": 202,
"_connect_ms": 32,
"_ssl_ms": "-1",
"_gzip_total": "3180",
"_gzip_save": "0",
"_minify_total": "0",
"_minify_save": "0",
"_image_total": "0",
"_image_save": "0",
"_cache_time": "-1",
"_dns_start": "2395",
"_dns_end": "2597",
"_connect_start": "2600",
"_connect_end": "2632",
"_ssl_start": "0",
"_ssl_end": "0",
"_initiator": "http://echosdunet.disqus.com/embed.js?_=1451859532217",
"_initiator_line": "16",
"_initiator_column": "8205",
"_server_count": "4",
"_server_rtt": "32",
"_client_port": "62284",
"_jpeg_scan_count": "0",
"_full_url": "http://disqus.com/embed/comments/?base=default&version=f3e1717b71e7256da258d3a504e56865&f=echosdunet&t_i=node%2F19849&t_u=http%3A%2F%2Fwww.echosdunet.net%2Fnode%2F19849&t_e=Accueil&t_d=Comparatif%20et%20test%20ADSL%20et%20fibre&t_t=Accueil&s_o=default&l=fr",
"_score_progressive_jpeg": -1,
"_body": true,
"_load_end": 2850,
"_ttfb_start": "2632",
"_ttfb_end": 2740,
"_download_start": 2740,
"_download_end": 2850,
"_download_ms": 110,
"_all_start": "2395",
"_all_end": 2850,
"_all_ms": 452,
"_index": 55,
"_number": 56,
"_body_url": "/response_body.php?test=160101_10_KZQ1&run=1&cached=0&request=56"
}
Running the query without the referer jsonPath works fine:
SELECT
JSON_EXTRACT(payload,"$._host")AS host,
url,
payload
FROM
[httparchive:har.2016_01_01_chrome_requests]
LIMIT
100

Meantime, try below (for BigQuery Standard SQL)
#standardSQL
CREATE TEMPORARY FUNCTION CUSTOM_JSON_EXTRACT(json STRING, key String)
RETURNS string
LANGUAGE js AS """
try {
var parsed = JSON.parse(json);
for (i = 0; i < parsed.length; i++) {
if (parsed[i].name == key) return parsed[i].value
}
} catch (e) {}
return null;
""";
SELECT
JSON_EXTRACT(payload,"$._host")AS host,
CUSTOM_JSON_EXTRACT(JSON_EXTRACT(payload, "$.request.headers"), 'Referer') AS referer,
url,
payload
FROM
`httparchive.har.2016_01_01_chrome_requests`
LIMIT
100

JSON_EXTRACT and JSON_EXTRACT_SCALAR do not support the complete set of JSONPath elements. You can read more in the documentation. I would suggest using standard SQL since that implementation of the JSON functions has better error messages.
If you are interested in additional kinds of JSONPath elements, you can consider submitting a feature request.

Related

How can I extract subdomains from a json file?

I have a long list of json file . I want to extract the subdomain of harvard.edu which is in the variable host in "host": "ceonlineb2b.hms.harvard.edu using bash . I would be happy if anyone can help out .Below is only a snippet of json file.
{
"data": {
"total_items": 3,
"offset": 0,
"limit": 1,
"items": [
{
"name": "ceonlineb2b.hms.harvard.edu",
"alexa": null,
"cert_summary": null,
"dns_records": {
"A": [
"3.221.168.206",
"54.174.253.3"
],
"AAAA": null,
"CAA": null,
"CNAME": [
"hms-moodleb2b-prod.cabem.com"
],
"MX": null,
"NS": null,
"SOA": null,
"TXT": null,
"SPF": null,
"updated_at": "2021-05-14T23:12:43.332816923Z"
},
"hosts_enrichment": [
{
"ip": "3.221.168.206",
"as_num": 14618,
"as_org": "amazon-aes",
"isp": "amazon.com",
"city_name": "ashburn",
"country": "united states",
"country_iso_code": "us",
"location": {
"lat": 39.0481,
"lon": -77.4728
}
},
{
"ip": "54.174.253.3",
"as_num": 14618,
"as_org": "amazon-aes",
"isp": "amazon.com",
"city_name": "ashburn",
"country": "united states",
"country_iso_code": "us",
"location": {
"lat": 39.0481,
"lon": -77.4728
}
}
],
"http_extract": {
"cookies": [
{
"domain": "",
"expire": "0001-01-01T00:00:00Z",
"http_only": true,
"key": "MoodleSession",
"max_age": 0,
"path": "/",
"security": true,
"value": "tqhmqc4muk513sad1bmnl3kocj"
}
],
"description": "",
"emails": null,
"final_redirect_url": {
"full_uri": "https://ceonlineb2b.hms.harvard.edu/login/index.php",
"host": "ceonlineb2b.hms.harvard.edu",
"path": "/login/index.php"
},
"extracted_at": "2020-10-04T20:55:26.043777194Z",
"favicon_sha256": "",
"http_headers": [
{
"name": "date",
"value": "Sun, 04 Oct 2020 20:55:25 GMT"
},
{
"name": "content-type",
"value": "text/html; charset=utf-8"
},
{
"name": "server",
"value": "Apache/2.4.46 () OpenSSL/1.0.2k-fips"
},
{
"name": "x-powered-by",
"value": "PHP/7.2.24"
},
{
"name": "content-language",
"value": "en"
},
{
"name": "content-script-type",
"value": "text/javascript"
},
{
"name": "content-style-type",
"value": "text/css"
},
{
"name": "x-ua-compatible",
"value": "IE=edge"
},
{
"name": "cache-control",
"value": "private, pre-check=0, post-check=0, max-age=0, no-transform"
},
{
"name": "pragma",
"value": "no-cache"
},
{
"name": "expires",
"value": ""
},
{
"name": "accept-ranges",
"value": "none"
},
{
"name": "set-cookie",
"value": "MoodleSession=tqhmqc4muk513sad1bmnl3kocj; path=/; secure;HttpOnly;Secure;SameSite=None"
}
],
"http_status_code": 200,
"links": [
{
"anchor": "Forgotten your username or password?",
"url": "https://ceonlineb2b.hms.harvard.edu/login/forgot_password.php",
"url_host": "ceonlineb2b.hms.harvard.edu"
},
{
"anchor": "Privacy Statement",
"url": "/local/staticpage/view.php?page=privacy-statement",
"url_host": ""
},
{
"anchor": "Terms of Service",
"url": "/local/staticpage/view.php?page=terms-of-service",
"url_host": ""
},
{
"anchor": "Copyright Information",
"url": "/local/staticpage/view.php?page=copyright-information",
"url_host": ""
}
],
"meta_tags": [
{
"name": "keywords",
"value": "moodle, HMS Postgraduate Courses: Log in to the site"
},
{
"name": "format-detection",
"value": "telephone=no"
},
{
"name": "robots",
"value": "noindex"
},
{
"name": "viewport",
"value": "width=device-width, initial-scale=1.0"
}
],
"robots_txt": "",
"scripts": [
"https://ceonlineb2b.hms.harvard.edu/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.js",
"https://ceonlineb2b.hms.harvard.edu/lib/javascript.php/1589465014/lib/javascript-static.js",
"https://ceonlineb2b.hms.harvard.edu/lib/javascript.php/1589465014/lib/requirejs/require.min.js",
"https://ceonlineb2b.hms.harvard.edu/theme/javascript.php/hms/1589465013/footer"
],
"styles": [
"https://ceonlineb2b.hms.harvard.edu/theme/yui_combo.php?rollup/3.17.2/yui-moodlesimple-min.css",
"https://ceonlineb2b.hms.harvard.edu/theme/styles.php/hms/1589465013_1/all"
],
"title": "HMS Postgraduate Courses: Log in to the site"
},
"is_CNAME": null,
"is_MX": null,
"is_NS": null,
"is_PTR": null,
"is_subdomain": true,
"name_without_suffix": "ceonlineb2b.hms.harvard",
"updated_at": "2021-05-16T10:25:01.59086376Z",
"user_scan_at": null,
"whois_parsed": null,
"security_score": {
"score": 100
},
"cve_list": null,
"technologies": [
{
"name": "Moodle",
"version": ""
},
{
"name": "RequireJS",
"version": ""
}
],
"trackers": null,
"organizations": null
}
]
}
}
For json parsing on bash, I recommend checking out jq. It's lightweight and versatile.
We can use the -r flag to output only values.
Output the fields of each object with the keys in sorted order.
--raw-output / -r:
The structure of the JSON you provided has the subdomain at .data.items[].http_extract.final_redirect_url.host
{
"data": {
"items": [
{
"http_extract": {
"final_redirect_url": {
"full_uri": "https://ceonlineb2b.hms.harvard.edu/login/index.php",
"host": "ceonlineb2b.hms.harvard.edu",
"path": "/login/index.php"
},
...
I've saved your json to a file, se.json
Example extracting full domain with jq
jq -r '.data.items[].http_extract.final_redirect_url.host' se.json
Output
ceonlineb2b.hms.harvard.edu
To extract the subdomain, just perform a search/replace using sub().
sub(regex; tostring) sub(regex; string; flags)
Emit the string obtained by replacing the first match of regex in the input string with tostring, after interpolation. tostring should be a jq string, and may contain references to named captures. The named captures are, in effect, presented as a JSON object (as constructed by capture) to tostring, so a reference to a captured variable named "x" would take the form: "(.x)".
Extracting subdomain using jq
jq -r '.data.items[].http_extract.final_redirect_url.host | sub(".hms.harvard.edu";"")' se.json
Output
ceonlineb2b

How to confirm Webhook POST is being received in Coldfusion

To be clear upfront, I'm not a professional - just trying to get a task done and I have minimal expertise. What I thought would be easy is apparently not so. I've dealt with APIs and XML but it's always been me initiating. This is apparently different.
Goal:
Receive HTTP POST Webhook data (JSON) from my Wordpress/Woocommerce website.
Problem:
The Webhook is working and being received perfectly by RequestBin.The JSON string is being sent over HTTP. But I'm not even sure the request is being heard by my CF Template. When I try to write the received data into a session variable so I can at least see it, nothing is there?!?! How do I find out if my code being triggered?
First line of code in my CF Template:
<cfset HTTPRequestData = deserializeJSON(ToString(getHTTPRequestData().content))>
Example from RequestBin of data being sent:
{
"id": 259609,
"parent_id": 0,
"number": "CW-104-270219",
"order_key": "xxxxxxxxxxxx",
"created_via": "checkout",
"version": "3.5.5",
"status": "completed",
"currency": "USD",
"date_created": "2019-02-27T15:11:58",
"date_created_gmt": "2019-02-27T20:11:58",
"date_modified": "2019-02-27T15:11:59",
"date_modified_gmt": "2019-02-27T20:11:59",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "9.68",
"total_tax": "0.00",
"prices_include_tax": false,
"customer_id": 2,
"customer_ip_address": "xxxxxxxxxxxx",
"customer_user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36",
"customer_note": "",
"billing": {
"first_name": "Valerie",
"last_name": "Criswell",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": "",
"email": "xxxxxxxxxx",
"phone": ""
},
"shipping": {
"first_name": "",
"last_name": "",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": ""
},
"payment_method": "authorize_net_aim",
"payment_method_title": "Credit Card",
"transaction_id": "xxxxxxxxxxxxx",
"date_paid": "2019-02-27T15:11:59",
"date_paid_gmt": "2019-02-27T20:11:59",
"date_completed": "2019-02-27T15:11:59",
"date_completed_gmt": "2019-02-27T20:11:59",
"cart_hash": "xxxxxxxxxxxxx",
"meta_data": [
{
"id": 8785641,
"key": "_wcson_order_number",
"value": "CWD-259609-022719-108"
},
{
"id": 8785642,
"key": "_order_number",
"value": "104"
},
{
"id": 8785643,
"key": "_order_number_formatted",
"value": "CW-104-270219"
},
{
"id": 8785644,
"key": "_order_number_meta",
"value": {
"prefix": "CW-",
"suffix": "-{DD}{MM}{YY}",
"length": "2"
}
},
{
"id": 8785645,
"key": "_wc_authorize_net_aim_retry_count",
"value": "0"
},
{
"id": 8785646,
"key": "_wc_authorize_net_aim_trans_id",
"value": "xxxxxxxx"
},
{
"id": 8785647,
"key": "_wc_authorize_net_aim_trans_date",
"value": "2019-02-27 15:11:59"
},
{
"id": 8785648,
"key": "_wc_authorize_net_aim_environment",
"value": "production"
},
{
"id": 8785649,
"key": "_wc_authorize_net_aim_account_four",
"value": "xxxxxxxx"
},
{
"id": 8785650,
"key": "_wc_authorize_net_aim_authorization_amount",
"value": "xxxxxxx"
},
{
"id": 8785651,
"key": "_wc_authorize_net_aim_authorization_code",
"value": "xxxxxxx"
},
{
"id": 8785652,
"key": "_wc_authorize_net_aim_charge_captured",
"value": "yes"
},
{
"id": 8785653,
"key": "_wc_authorize_net_aim_card_expiry_date",
"value": "21-08"
},
{
"id": 8785654,
"key": "_wc_authorize_net_aim_card_type",
"value": "mastercard"
},
{
"id": 8785659,
"key": "_pip_invoice_number",
"value": "CW-104-270219"
},
{
"id": 8785660,
"key": "_wc_pip_invoice_email_count",
"value": "1"
},
{
"id": 8785661,
"key": "_wc_pip_packing_list_email_count",
"value": "1"
}
],
"line_items": [
{
"id": 17,
"name": "I Give Myself Away - MP3 Download - 30 Day Access",
"product_id": 192127,
"variation_id": 192128,
"quantity": 1,
"tax_class": "",
"subtotal": "9.68",
"subtotal_tax": "0.00",
"total": "9.68",
"total_tax": "0.00",
"taxes": [],
"meta_data": [
{
"id": 182,
"key": "pa_format",
"value": "download-30-day"
}
],
"sku": "131599-DL30DAY",
"price": 9.68
}
],
"tax_lines": [],
"shipping_lines": [],
"fee_lines": [],
"coupon_lines": [],
"refunds": []
}
Let's start with the stated goal:
Receive HTTP POST Webhook data from my Wordpress/Woocommerce website.
Can your Wordpress site hit the intended URL on your ColdFusion site? If so, can you record / dump the HTTP POST request to a file?
<cfdump var="#form#" format="html" output="/full/path/to/file">
This will tell you if you're even receiving the request correctly.

Azure API Management latency of over 5 seconds

We're using API Management to execute an always on function app that, in turn, is calling Azure Search. The function app responds within 100 ms (usually well under), but API Management intermittently takes 3 to 8 seconds to process. I've gone through the trace and found the delay is consistently in the backend step in which API Management is processing the results (sample trace for backend below). The returned data in this case is 664 bytes. Does anyone know what may cause this and, more importantly, how to remove this latency?
The Azure API Management instance, function app, and Azure Search are all in the same region.
"backend": [
{
"source": "forward-request",
"timestamp": "2018-10-11T13:33:54.0578250Z",
"elapsed": "00:00:00.0005890",
"data": {
"message": "Request is being forwarded to the backend service. Timeout set to 300 seconds",
"request": {
"method": "GET",
"url": "https://ommitted.azurewebsites.net/api/HollanderSearch/?hollander=125-222L&websiteId=1&retrieveAllProductNames=false&onlyRetrieveProductNames=true&numRecsToRetrieve =25&code=%2Fxu1iz0EimDFnOUvhDVaM4ZejfaW7umV3somaIDCeWJYI5RMIfNnNg%3D%3D&keyword=125-222L",
"headers": [
{
"name": "Ocp-Apim-Subscription-Key",
"value": "ommitted"
},
{
"name": "Postman-Token",
"value": "9e809f11-6e63-4422-8c3f-d61962cec6ac"
},
{
"name": "Cache-Control",
"value": "no-cache"
},
{
"name": "Accept",
"value": "*/*"
},
{
"name": "Accept-Encoding",
"value": "gzip,deflate"
},
{
"name": "User-Agent",
"value": "PostmanRuntime/7.3.0"
},
{
"name": "X-Forwarded-For",
"value": "omitted"
}
]
}
}
},
{
"source": "forward-request",
"timestamp": "2018-10-11T13:33:59.6717259Z",
"elapsed": "00:00:05.6045857",
"data": {
"response": {
"status": {
"code": 200,
"reason": "OK"
},
"headers": [
{
"name": "Pragma",
"value": "no-cache"
},
{
"name": "Transfer-Encoding",
"value": "chunked"
},
{
"name": "Content-Encoding",
"value": "gzip"
},
{
"name": "Vary",
"value": "Accept-Encoding"
},
{
"name": "Cache-Control",
"value": "no-cache"
},
{
"name": "Content-Type",
"value": "application/json; charset=utf-8"
},
{
"name": "Date",
"value": "Thu, 11 Oct 2018 13:33:59 GMT"
},
{
"name": "Expires",
"value": "-1"
},
{
"name": "Set-Cookie",
"value": "ARRAffinity=8065e5ea6c0774f598f30cd38416a122cd6afe1af34a15c7f6430e1a0fe9924c;Path=/;HttpOnly;Domain=omitted-dev.azurewebsites.net"
},
{
"name": "Server",
"value": "Microsoft-IIS/10.0"
},
{
"name": "X-Powered-By",
"value": "ASP.NET"
}
]
}
}
},
{
"source": "decompressor",
"timestamp": "2018-10-11T13:33:59.6717259Z",
"elapsed": "00:00:05.6045976",
"data": "Content-Encoding header with value `gzip` detected in message headers. Content re-compression may require to correctly apply content modification policies."
}
]

Extract some value from JSON using JsonPath with != condition in Jmeter

I have the following JSON and I need to get id values for instances which do not have type = Jenkins
{
"data": [
{
"id": "35002399-6fd7-40b7-b0d0-8be64e4ec09c",
"name": "94Jenkins",
"url": "http://127.0.0.1:8084",
"authProvider": false,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "InstanceStateDto",
"version": "2.60.3"
},
"adminUser": "admin1",
"hasDRConfig": false,
"managed": true,
"type": "JENKINS",
"siteName": "City",
"lastRefreshTime": "2018-04-24T09:43:01.694Z"
},
{
"id": "5cd3caf6-bac1-4f07-8793-5f124b90eaf5",
"name": "RJO",
"url": "http://test.com",
"authProvider": false,
"status": {
"status": "UNAUTHORIZED"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.5.2-m002",
"licenses": {
"RJO : artrjo-m": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "Test",
"licenseHash": "asdadsdb612bda1aae745bd2a3",
"expired": false
},
"RJO : artrjo-s1": {
"type": "ENTERPRISE",
"validThrough": "Jun 12, 2021",
"licensedTo": "JFrog",
"licenseHash": "asaswca236350205a3798c0fa3",
"expired": false
}
}
},
"adminUser": "jfmc",
"hasDRConfig": false,
"managed": false,
"warnings": [
"Site is missing",
"Failed to connect to the service. Please verify that the service information provided is correct."
],
"type": "ARTIFACTORY"
},
{
"id": "0727a49a-6c95-433e-9fc5-7e5c760cc76f",
"name": "NinetyTwo",
"url": "http:127.0.0.1:8081",
"authProvider": true,
"siteId": "cce1b6e2-4b5d-4455-ac96-6b5d4c0d901d",
"status": {
"status": "ONLINE"
},
"instanceStateReady": true,
"instanceState": {
"#type": "numberOfArtifacts",
"version": "5.9.0",
"licenses": {
"NinetyTwo": {
"type": "ENTERPRISE",
"validThrough": "Dec 30, 2018",
"licensedTo": "Test",
"licenseHash": "qweqwed95f712dbabee98184da52443",
"expired": false
}
}
},
"adminUser": "admin",
"hasDRConfig": false,
"managed": true,
"type": "ARTIFACTORY",
"serviceId": "jfrt#01c7g4c7hq0dpd0qa71r8c09sj",
"siteName": "Test",
"lastRefreshTime": "2018-04-24T09:43:01.698Z"
}
]
}
And I use $..[?(#.type!='JENKINS')].id path to receive id-s which relate to the instances with type NOT JENKINS, however JSON Extractor returns me the Jenkins's id too. The question is how can I receive ids for non-jenkins instances only?
Replace your JSON path expression with the below and it should work:
$.data.[*][?(#.type != "JENKINS")].id

Why aren't the 2nd and 3rd requests for the same image cached?

The original website isn't caching html, css, or images the way I think it should. The results from google chrome har for just a single image while requesting different pages on the website are below. It is part of a larger browsing of a website trying to figure out why the browser thinks it should be cached but the browser is re-requested from server. I removed all har not specificially related to this image.
I don't have any cache-killer or cache-disabler on. I even went to relatively clean computer to make sure there weren't any dev tools installed that might mess with the cache.
All the request/response headers from the first request appear to imply that the 2nd and 3rd requests should not make re-requests but come from browser local cache.
What am I missing?
{
"startedDateTime": "2017-02-10T21:21:44.273Z",
"time": 56.46199999999624,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png",
"compression": 0
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 6397,
"_transferSize": 6830
},
"cache": {},
"timings": {
"blocked": 0.396999999992431,
"dns": -1,
"connect": -1,
"send": 0.13800000000685503,
"wait": 23.861999999994016,
"receive": 32.06500000000294,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_1"
},
{
"startedDateTime": "2017-02-10T21:22:48.357Z",
"time": 0,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png"
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": -1,
"dns": -1,
"connect": -1,
"send": 0,
"wait": 0,
"receive": 0,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_2"
}
{
"startedDateTime": "2017-02-10T21:23:38.412Z",
"time": 0,
"request": {
"method": "GET",
"url": "http://616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com/images/default-source/site-cdn/LoginLogo.png",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept",
"value": "image/webp,image/*,*/*;q=0.8"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch"
},
{
"name": "Referer",
"value": "http://authentrip.com/"
},
{
"name": "Host",
"value": "616206ee2c1b2155fd11-21abbde6fa52e03b7fd037b3488bb991.r53.cf1.rackcdn.com"
},
{
"name": "Accept-Language",
"value": "en-US,en;q=0.8"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36"
}
],
"queryString": [],
"cookies": [],
"headersSize": 428,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 10 Feb 2017 21:21:44 GMT"
},
{
"name": "Origin",
"value": "https://mycloud.rackspace.com"
},
{
"name": "Last-Modified",
"value": "Fri, 09 Dec 2016 05:10:48 GMT"
},
{
"name": "ETag",
"value": "ab904584a8e355da2fd0437065839e10"
},
{
"name": "Content-Type",
"value": "image/png"
},
{
"name": "X-Timestamp",
"value": "1481260247.52133"
},
{
"name": "Cache-Control",
"value": "public, max-age=349"
},
{
"name": "Content-Length",
"value": "6397"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "X-Trans-Id",
"value": "txbeec00752b6a4e1e9e3b5-00589e2ca4dfw1"
},
{
"name": "Expires",
"value": "Fri, 10 Feb 2017 21:27:33 GMT"
}
],
"cookies": [],
"content": {
"size": 6397,
"mimeType": "image/png"
},
"redirectURL": "",
"headersSize": 433,
"bodySize": 0,
"_transferSize": 0
},
"cache": {},
"timings": {
"blocked": -1,
"dns": -1,
"connect": -1,
"send": 0,
"wait": 0,
"receive": 0,
"ssl": -1
},
"serverIPAddress": "204.2.145.184",
"connection": "989",
"pageref": "page_3"
}
In fact Chrome does served responses to second and third requests from cache. You need to look at entry.response.bodySize property.
Relevant excerpt from HAR specification:
bodySize [number] - Size of the received response body in bytes. Set to zero in case of responses coming from the cache (304). Set to -1 if the info is not available.
There is also interesting HAR Viewer GitHub issue. They use function below to determine whether response to request was served from cache:
HarModel.isCachedEntry = function(entry) {
var response = entry.response;
var resBodySize = response.bodySize > 0 ? response.bodySize : 0;
return (response.status == 304 || (resBodySize === 0 && response.content && response.content.size > 0));
};