Help with reading response of assets API.

ahzam
Tourist
13 0 1

The HTML of the file contents change in the API response, this is encoded data obviously due to security reasons.

This is the response I am getting after requesting the API:

\u003c!doctype html\u003e\n\u003chtml class=\"no-js\" lang=\"{{ request.locale.iso_code }}\"\u003e\n\u003chead\u003e\n  \u003cmeta charset=\"utf-8\"\u003e\n  \u003cmeta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"\u003e\n  \u003cmeta name=\"viewport\" content=\"width=device-width,initial-scale=1\"\u003e\n  \u003cmeta name=\"theme-color\" content=\"{{ settings.color_button }}\"\u003e\n\n  \u003clink rel=\"preconnect\" href=\"https:\/\/cdn.shopify.com\" crossorigin\u003e\n  \u003clink rel=\"preconnect\" href=\"https:\/\/fonts.shopifycdn.com\" crossorigin\u003e\n  \u003clink rel=\"preconnect\" href=\"https:\/\/monorail-edge.shopifysvc.com\"\u003e\n\n  {%- assign header_font = settings.type_header_font -%}\n  {%- assign base_font = settings.type_base_font -%}\n  {%- assign base_font_bolder = base_font | font_modify: 'weight', 'bolder' -%}\n  {%- assign base_font_bold = base_font | font_modify: 'weight', 'bold' -%}\n  {%- assign base_font_italic = base_font | font_modify: 'style', 'italic' -%}\n  {%- assign base_font_bold_italic = base_font_bold | font_modify: 'style', 'italic' -%}\n\n  \u003clink rel=\"preload\" href=\"{{ 'theme.css' | asset_url }}\" as=\"style\"\u003e\n  \u003clink rel=\"preload\" as=\"font\" href=\"{{ header_font | font_url }}\" type=\"font\/woff2\" crossorigin\u003e\n  \u003clink rel=\"preload\" as=\"font\" href=\"{{ base_font | font_url }}\" type=\"font\/woff2\" crossorigin\u003e\n  \u003clink rel=\"preload\" as=\"font\" href=\"{{ base_font_bold | font_url }}\" type=\"font\/woff2\" crossorigin\u003e\n  \u003clink rel=\"preload\" href=\"{{ 'theme.js' | asset_url }}\" as=\"script\"\u003e\n  \u003clink rel=\"preload\" href=\"{{ 'lazysizes.js' | asset_url }}\" as=\"script\"\u003e\n\n  {%- if canonical_url != blank  -%}\n    \u003clink rel=\"canonical\" href=\"{{ canonical_url }}\"\u003e\n  {%- endif -%}\n\n  {%- if settings.favicon != blank -%}\n    \u003clink rel=\"shortcut icon\" href=\"{{ settings.favicon | img_url: '32x32' }}\" type=\"image\/png\"\u003e\n  {%- endif -%}\n\n  {%- capture seo_title -%}\n    {%- if request.page_type == 'search' and search.performed == true -%}\n      {{ 'general.search.heading' | t: count: search.results_count }}: {{ 'general.search.results_with_count' | t: terms: search.terms, count: search.results_count }}\n    {%- else -%}\n      {{ page_title }}\n    {%- endif -%}\n    {%- if current_tags -%}\n      {%- assign meta_tags = current_tags | join: ', ' -%} \u0026ndash; {{ 'general.meta.tags' | t: tags: meta_tags -}}\n    {%- endif -%}\n    {%- if current_page != 1 -%}\n      \u0026ndash; {{ 'general.meta.page' | t: page: current_page }}\n    {%- endif -%}\n    {%- assign escaped_page_title = page_title | escape -%}\n    {%- unless escaped_page_title contains shop.name -%}\n      \u0026ndash; {{ shop.name }}\n    {%- endunless -%}\n  {%- endcapture -%}\n  \u003ctitle\u003e{{ seo_title | strip }}\u003c\/title\u003e\n\n  {%- if page_description -%}\n    \u003cmeta name=\"description\" content=\"{{ page_description | escape }}\"\u003e\n  {%- endif -%}\n\n  {% include 'social-meta-tags' %}\n  {% include 'css-variables' %}\n\n  \u003cstyle\u003e*,::after,::before{box-sizing:border-box}body{margin:0}body,html{background-color:var(--color-body)}body,button{font-size:calc(var(--font-size-base) * 1px);font-family:var(--font-stack-body);font-style:var(--font-style-body);font-weight:var(--font-weight-body);color:var(--color-text);line-height:1.5}body,button{-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%}.border-bottom{border-bottom:1px solid var(--color-border)}.btn--link{background-color:transparent;border:0;margin:0;color:var(--color-text);text-align:left}.text-right{text-align:right}.icon{display:inline-block;width:20px;height:20px;vertical-align:middle;fill:currentColor}.icon__fallback-text,.visually-hidden{position:absolute!important;overflow:hidden;clip:rect(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0}svg.icon:not(.icon--full-color) circle,svg.icon:not(.icon--full-color) ellipse,svg.icon:not(.icon--full-color) g,svg.icon:not(.icon--full-color) line,svg.icon:not(.icon--full-color) path,svg.icon:not(.icon--full-color) polygon,svg.icon:not(.icon--full-color) polyline,svg.icon:not(.icon--full-color) rect,symbol.icon:not(.icon--full-color) circle,symbol.icon:not(.icon--full-color) ellipse,symbol.icon:not(.icon--full-color) g,symbol.icon:not(.icon--full-color) line,symbol.icon:not(.icon--full-color) path,symbol.icon:not(.icon--full-color) polygon,symbol.icon:not(.icon--full-color) polyline,symbol.icon:not(.icon--full-color) rect{fill:inherit;stroke:inherit}li{list-style:none}.list--inline{padding:0;margin:0}.list--inline\u003eli{display:inline-block;margin-bottom:0;vertical-align:middle}a{color:var(--color-text);text-decoration:none}.h1,.h2,h1,h2{margin:0 0 17.5px;font-family:var(--font-stack-header);font-style:var(--font-style-header);font-weight:var(--font-weight-header);line-height:1.2;overflow-wrap:break-word;word-wrap:break-word}.h1 a,.h2 a,h1 a,h2 a{color:inherit;text-decoration:none;font-weight:inherit}.h1,h1{font-size:calc(((var(--font-h1-desktop))\/ (var(--font-size-base))) * 1em);text-transform:none;letter-spacing:0}@media only screen and (max-width:749px){.h1,h1{font-size:calc(((var(--font-h1-mobile))\/ (var(--font-size-base))) * 1em)}}.h2,h2{font-size:calc(((var(--font-h2-desktop))\/ (var(--font-size-base))) * 1em);text-transform:uppercase;letter-spacing:.1em}@media only screen and (max-width:749px){.h2,h2{font-size:calc(((var(--font-h2-mobile))\/ (var(--font-size-base))) * 1em)}}p{color:var(--color-body-text);margin:0 0 19.44444px}@media only screen and (max-width:749px){p{font-size:calc(((var(--font-size-base) - 1)\/ (var(--font-size-base))) * 1em)}}p:last-child{margin-bottom:0}@media only screen and (max-width:749px){.small--hide{display:none!important}}.grid{list-style:none;margin:0;padding:0;margin-left:-30px}.grid::after{content:'';display:table;clear:both}@media only screen and (max-width:749px){.grid{margin-left:-22px}}.grid::after{content:'';display:table;clear:both}.grid--no-gutters{margin-left:0}.grid--no-gutters .grid__item{padding-left:0}.grid--table{display:table;table-layout:fixed;width:100%}.grid--table\u003e.grid__item{float:none;display:table-cell;vertical-align:middle}.grid__item{float:left;padding-left:30px;width:100%}@media only screen and (max-width:749px){.grid__item{padding-left:22px}}.grid__item[class*=\"--push\"]{position:relative}@media only screen and (min-width:750px){.medium-up--one-quarter{width:25%}.medium-up--push-one-third{width:33.33%}.medium-up--one-half{width:50%}.medium-up--push-one-third{left:33.33%;position:relative}}.site-header{position:relative;background-color:var(--color-body)}@media only screen and (max-width:749px){.site-header{border-bottom:1px solid var(--color-border)}}@media only screen and (min-width:750px){.site-header{padding:0 55px}.site-header.logo--center{padding-top:30px}}.site-header__logo{margin:15px 0}.logo-align--center .site-header__logo{text-align:center;margin:0 auto}@media only screen and (max-width:749px){.logo-align--center .site-header__logo{text-align:left;margin:15px 0}}@media only screen and (max-width:749px){.site-header__logo{padding-left:22px;text-align:left}.site-header__logo img{margin:0}}.site-header__logo-link{display:inline-block;word-break:break-word}@media only screen and (min-width:750px){.logo-align--center .site-header__logo-link{margin:0 auto}}.site-header__logo-image{display:block}@media only screen and (min-width:750px){.site-header__logo-image{margin:0 auto}}.site-header__logo-image img{width:100%}.site-header__logo-image--centered img{margin:0 auto}.site-header__logo img{display:block}.site-header__icons{position:relative;white-space:nowrap}@media only screen and (max-width:749px){.site-header__icons{width:auto;padding-right:13px}.site-header__icons .btn--link,.site-header__icons .site-header__cart{font-size:calc(((var(--font-size-base))\/ (var(--font-size-base))) * 1em)}}.site-header__icons-wrapper{position:relative;display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-o-align-items:center;align-items:center;-webkit-justify-content:flex-end;-ms-justify-content:flex-end;justify-content:flex-end}.site-header__account,.site-header__cart,.site-header__search{position:relative}.site-header__search.site-header__icon{display:none}@media only screen and (min-width:1400px){.site-header__search.site-header__icon{display:block}}.site-header__search-toggle{display:block}@media only screen and (min-width:750px){.site-header__account,.site-header__cart{padding:10px 11px}}.site-header__cart-title,.site-header__search-title{position:absolute!important;overflow:hidden;clip:rect(0 0 0 0);height:1px;width:1px;margin:-1px;padding:0;border:0;display:block;vertical-align:middle}.site-header__cart-title{margin-right:3px}.site-header__cart-count{display:flex;align-items:center;justify-content:center;position:absolute;right:.4rem;top:.2rem;font-weight:700;background-color:var(--color-btn-primary);color:var(--color-btn-primary-text);border-radius:50%;min-width:1em;height:1em}.site-header__cart-count span{font-family:HelveticaNeue,\"Helvetica Neue\",Helvetica,Arial,sans-serif;font-size:calc(11em \/ 16);line-height:1}@media only screen and (max-width:749px){.site-header__cart-count{top:calc(7em \/ 16);right:0;border-radius:50%;min-width:calc(19em \/ 16);height:calc(19em \/ 16)}}@media only screen and (max-width:749px){.site-header__cart-count span{padding:.25em calc(6em \/ 16);font-size:12px}}.site-header__menu{display:none}@media only screen and (max-width:749px){.site-header__icon{display:inline-block;vertical-align:middle;padding:10px 11px;margin:0}}@media only screen and (min-width:750px){.site-header__icon .icon-search{margin-right:3px}}.announcement-bar{z-index:10;position:relative;text-align:center;border-bottom:1px solid transparent;padding:2px}.announcement-bar__link{display:block}.announcement-bar__message{display:block;padding:11px 22px;font-size:calc(((16)\/ (var(--font-size-base))) * 1em);font-weight:var(--font-weight-header)}@media only screen and (min-width:750px){.announcement-bar__message{padding-left:55px;padding-right:55px}}.site-nav{position:relative;padding:0;text-align:center;margin:25px 0}.site-nav a{padding:3px 10px}.site-nav__link{display:block;white-space:nowrap}.site-nav--centered .site-nav__link{padding-top:0}.site-nav__link .icon-chevron-down{width:calc(8em \/ 16);height:calc(8em \/ 16);margin-left:.5rem}.site-nav__label{border-bottom:1px solid transparent}.site-nav__link--active .site-nav__label{border-bottom-color:var(--color-text)}.site-nav__link--button{border:none;background-color:transparent;padding:3px 10px}.site-header__mobile-nav{z-index:11;position:relative;background-color:var(--color-body)}@media only screen and (max-width:749px){.site-header__mobile-nav{display:-webkit-flex;display:-ms-flexbox;display:flex;width:100%;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;-ms-align-items:center;-o-align-items:center;align-items:center}}.mobile-nav--open .icon-close{display:none}.main-content{opacity:0}.main-content .shopify-section{display:none}.main-content .shopify-section:first-child{display:inherit}.critical-hidden{display:none}\u003c\/style\u003e\n\n  \u003cscript\u003e\n    window.performance.mark('debut:theme_stylesheet_loaded.start');\n\n    function onLoadStylesheet() {\n      performance.mark('debut:theme_stylesheet_loaded.end');\n      performance.measure('debut:theme_stylesheet_loaded', 'debut:theme_stylesheet_loaded.start', 'debut:theme_stylesheet_loaded.end');\n\n      var url = \"{{ 'theme.css' | asset_url }}\";\n      var link = document.querySelector('link[href=\"' + url + '\"]');\n      link.loaded = true;\n      link.dispatchEvent(new Event('load'));\n    }\n  \u003c\/script\u003e\n\n  \u003clink rel=\"stylesheet\" href=\"{{ 'theme.css' | asset_url }}\" type=\"text\/css\" media=\"print\" onload=\"this.media='all';onLoadStylesheet()\"\u003e\n\n  \u003cstyle\u003e\n    {{ header_font | font_face: font_display: 'swap' }}\n    {{ base_font | font_face: font_display: 'swap' }}\n    {{ base_font_bold | font_face: font_display: 'swap' }}\n    {{ base_font_bolder | font_face: font_display: 'swap' }}\n    {{ base_font_italic | font_face: font_display: 'swap' }}\n    {{ base_font_bold_italic | font_face: font_display: 'swap' }}\n  \u003c\/style\u003e\n\n  \u003cscript\u003e\n    var theme = {\n      breakpoints: {\n        medium: 750,\n        large: 990,\n        widescreen: 1400\n      },\n      strings: {\n        addToCart: {{ 'products.product.add_to_cart' | t | json }},\n        soldOut: {{ 'products.product.sold_out' | t | json }},\n        unavailable: {{ 'products.product.unavailable' | t | json }},\n        regularPrice: {{ 'products.product.regular_price' | t | json }},\n        salePrice: {{ 'products.product.sale_price' | t | json }},\n        sale: {{ 'products.product.on_sale' | t | json }},\n        fromLowestPrice: {{ 'products.product.from_lowest_price_html' | t: lowest_price: '[price]' | json }},\n        vendor: {{'products.product.vendor' | t | json }},\n        showMore: {{ 'general.filters.show_more' | t | json }},\n        showLess: {{ 'general.filters.show_less' | t | json }},\n        searchFor: {{ 'general.search.search_for' | t | json }},\n        addressError: {{ 'sections.map.address_error' | t | json }},\n        addressNoResults: {{ 'sections.map.address_no_results' | t | json }},\n        addressQueryLimit: {{ 'sections.map.address_query_limit_html' | t | json }},\n        authError: {{ 'sections.map.auth_error_html' | t | json }},\n        newWindow: {{ 'general.accessibility.link_messages.new_window' | t | json }},\n        external: {{ 'general.accessibility.link_messages.external' | t | json }},\n        newWindowExternal: {{ 'general.accessibility.link_messages.new_window_and_external' | t | json }},\n        removeLabel: {{ 'cart.label.remove' | t: product: '[product]' | json }},\n        update: {{ 'cart.label.update' | t | json }},\n        quantity: {{ 'cart.label.quantity' | t | json }},\n        discountedTotal: {{ 'cart.label.discounted_total' | t | json }},\n        regularTotal: {{ 'cart.label.regular_total' | t | json }},\n        priceColumn: {{ 'cart.label.price_column' | t | json }},\n        quantityMinimumMessage: {{ 'products.product.quantity_minimum_message' | t | json }},\n        cartError: {{ 'cart.general.cart_error' | t | json }},\n        removedItemMessage: {{ 'cart.general.removed_item_html' | t: quantity: '[quantity]', link: '[link]' | json }},\n        unitPrice: {{ 'products.product.unit_price_label' | t | json }},\n        unitPriceSeparator: {{ 'general.accessibility.unit_price_separator' | t | json }},\n        oneCartCount: {{ 'cart.popup.cart_count' | t: count: 1 | json }},\n        otherCartCount: {{ 'cart.popup.cart_count' | t: count: '[count]' | json }},\n        quantityLabel: {{ 'cart.popup.quantity_label' | t: quantity_count: '[count]' | json }},\n        products: {{ 'general.search.products' | t | json }},\n        loading: {{ 'general.search.loading' | t | json }},\n        number_of_results: {{ 'general.search.number_of_results' | t: result_number: '[result_number]', results_count: '[results_count]' | json }},\n        number_of_results_found: {{ 'general.search.number_of_results_found' | t: results_count: '[results_count]' | json }},\n        one_result_found: {{ 'general.search.one_result_found' | t | json }}\n      },\n      moneyFormat: {{ shop.money_format | json }},\n      moneyFormatWithCurrency: {{ shop.money_with_currency_format | json }},\n      settings: {\n        predictiveSearchEnabled: {{ settings.predictive_search_enabled | json }},\n        predictiveSearchShowPrice: {{ settings.predictive_search_show_price | json }},\n        predictiveSearchShowVendor: {{ settings.predictive_search_show_vendor | json }}\n      },\n      stylesheet: \"{{ 'theme.css' | asset_url }}\"\n    }\n\n    document.documentElement.className = document.documentElement.className.replace('no-js', 'js');\n  \u003c\/script\u003e\n\n  {%- if request.page_type contains 'customers\/' -%}\n    \u003cscript src=\"{{ 'shopify_common.js' | shopify_asset_url }}\" defer=\"defer\"\u003e\u003c\/script\u003e\n  {%- endif -%}\n\n  \u003cscript src=\"{{ 'theme.js' | asset_url }}\" defer=\"defer\"\u003e\u003c\/script\u003e\n  \u003cscript src=\"{{ 'lazysizes.js' | asset_url }}\" async=\"async\"\u003e\u003c\/script\u003e\n\n  \u003cscript type=\"text\/javascript\"\u003e\n    if (window.MSInputMethodContext \u0026\u0026 document.documentMode) {\n      var scripts = document.getElementsByTagName('script')[0];\n      var polyfill = document.createElement(\"script\");\n      polyfill.defer = true;\n      polyfill.src=\"{{ 'ie11CustomProperties.min.js' | asset_url }}\";\n\n      scripts.parentNode.insertBefore(polyfill, scripts);\n    }\n  \u003c\/script\u003e\n\n  {{ content_for_header }}\n\u003c\/head\u003e\n\n\u003cbody class=\"template-{{ request.page_type | handle }}\"\u003e\n\n  \u003ca class=\"in-page-link visually-hidden skip-link\" href=\"#MainContent\"\u003e{{ 'general.accessibility.skip_to_content' | t }}\u003c\/a\u003e\n\n  {%- if settings.enable_ajax -%}\n    {% include 'cart-popup' %}\n  {%- endif -%}\n\n  {% section 'header' %}\n\n  \u003cdiv class=\"page-container drawer-page-content\" id=\"PageContainer\"\u003e\n\n    \u003cmain class=\"main-content js-focus-hidden\" id=\"MainContent\" role=\"main\" tabindex=\"-1\"\u003e\n      {{ content_for_layout }}\n    \u003c\/main\u003e\n\n    {% section 'footer' %}\n\n    \u003cdiv id=\"slideshow-info\" class=\"visually-hidden\" aria-hidden=\"true\"\u003e\n      {{- 'sections.slideshow.navigation_instructions' | t -}}\n    \u003c\/div\u003e\n\n  \u003c\/div\u003e\n\n  \u003cul hidden\u003e\n    \u003cli id=\"a11y-refresh-page-message\"\u003e{{ 'general.accessibility.refresh_page' | t }}\u003c\/li\u003e\n    \u003cli id=\"a11y-selection-message\"\u003e{{ 'general.accessibility.selection_help' | t }}\u003c\/li\u003e\n  \u003c\/ul\u003e\n\u003c\/body\u003e\n\u003c\/html\u003e\n

All the element tags get converted to '\u003c\'. I have tried to decode it with Base64 as well as UTF-8.
Both don't seem to work.

Any help would be appreciated.

Replies 0 (0)