1

I am trying to understand how etag works with the Youtube API. Here is the request I am making:

curl -X GET \
  'https://www.googleapis.com/youtube/v3/channels?part=statistics&fields=items&id=UCmRtPmgnQ04CMUpSUqPfhxQ' \
  -H 'Authorization: Bearer dezferfnr....' \
  -H 'Cache-Control: no-cache' \
  -H 'If-None-Match: \"g7k5f8kvn67Bsl8L-Bum53neIr4/4ygpLCFz2IoIJNkG3XO1Pys1hck\"'

And here is the response I am getting:

{
    "items": [
        {
            "kind": "youtube#channel",
            "etag": "\"g7k5f8kvn67Bsl8L-Bum53neIr4/4ygpLCFz2IoIJNkG3XO1Pys1hck\"",
            "id": "UCmRtPmgnQ04CMUpSUqPfhxQ",
            "statistics": {
                "viewCount": "4757859",
                "commentCount": "63",
                "subscriberCount": "68151",
                "hiddenSubscriberCount": false,
                "videoCount": "898"
            }
        }
    ]
}

As you can see, the etag found in the response is the same as the one I sent in the request's header, and I can't understand why I am not getting an HTTP 304 response (Not Modified) instead.

M. Abbas
  • 6,409
  • 4
  • 33
  • 46

1 Answers1

0

Try removing escaped double quotes from the beginning and the end of etag (leave the unescaped ones because they are part of etag):

curl -X GET \
    'https://www.googleapis.com/youtube/v3/channels?part=statistics&fields=items&id=UCmRtPmgnQ04CMUpSUqPfhxQ' \
    -H 'Authorization: Bearer dezferfnr....' \
    -H 'Cache-Control: no-cache' \
    -H 'If-None-Match: "g7k5f8kvn67Bsl8L-Bum53neIr4/4ygpLCFz2IoIJNkG3XO1Pys1hck"'

(use curl -i -X GET... to see the headers of response in CLI, you'll see 304 Status, otherwise it would just be empty string).