Status 415 "Unsupported Media Type" errors on simple Storefront API GraphQL queries

I’m getting Status 415 “Unsupported Media Type” errors on every storefront API GraphQL request I make. The Storefront API is enabled and I’ve double checked permissions and the storefront access token. Here are my request details:

Url:
https://erica-weiner.myshopify.com/api/2020-10/graphql

Headers:
‘Content-Type’: ‘application/json’,
‘X-Shopify-Storefront-Access-Token’: ‘155fd2311f650f31692e97758ad40ddc’

Query:
query Collection($handle:String!) {
{
collectionByHandle(handle: $handle){
id
title
handle
}
}
}

Full error log:

Error: Request failed with status code 415
at e.exports (/Users/davidgross/Sites/erica-weiner/web/functions/shopify-collection-sync.js:6:1780)
at e.exports (/Users/davidgross/Sites/erica-weiner/web/functions/shopify-collection-sync.js:6:10819)
at IncomingMessage.

After more troubleshooting I figured out the reason for my 415 errors and managed to get the requests working:

  1. The axios request headers did not include Accept: “application/json”,
Accept: "application/json"
  1. I had an extra set of brackets in my graphql query. Here’s the corrected query:
query Collection($handle:String!) { 
  collectionByHandle(handle: $handle){
    id
    title
    handle
    products(first:10) {
      edges {
        node {
          id
        }
      }
    }
  }
}

and 3. I was JSON.stringify-ing the axios data payload unnecessarily. Passing the data payload object directly without stringifying works.