0

I am using Twitch's API to gather data for a web app I'm developing.

Per the documentation,

I should be able to view these in the header response

However, when I make the request in Postman, I don't see it.

Not here.

They are in the header response section (I didn't screenshot the remaining half of the responses).

Am I looking in the wrong place?

I've looked in the Headers Response section of the API request I made. Additionally, I looked in the Headers Requests section in the console too.

VertPin
  • 11
  • 1

1 Answers1

0

The Headers Tab in Postman is request(input) headers not the response(output) headers data. It is located in the output area. enter image description here

You can see (or assign) the response headers at Test tab.

Also curl 's -v option can see the headers from tesminal.

curl --location 'http://localhost:5000/user' \
-v \
--header 'Content-Type: application/json' \
--data '{
    "username": "username",
    "password": "1234"
}'

Result enter image description here

You can see or assign to variable at Test Tab's by script

headers = pm.response.headers.all();
jsonHeader = JSON.stringify(headers);
console.log(jsonHeader)

headers.forEach(function(header){
    if(header.key == "Ratelimit-Reset"){
        pm.globals.set("Ratelimit-Reset", header.value)
        console.log(header.value)
        return;
    }    
})

enter image description here

you can assign global variable for specific key/value

enter image description here

Demo Server (emulate your Twitch's API server) by Python Flask.

app = Flask(__name__)

@app.route("/user", methods=["POST"])
def post_test():
    content_type = request.headers.get('Content-Type')
    if (content_type == 'application/json'):
        resp = Response(request.get_json())
        resp.headers['x-amzn-Requestid'] = '20122de8-3fd9-4439-b7f8-5c76a9dcf77e'
        resp.headers['x-amzn-Remapped-Content-Length'] = '6dd53770-ffa0-4f5f-95e6-b2fabe98c483'
        resp.headers['x-amz-apigw-id'] = 'e2994bb8-22c2-4ac5-b936-b541ac1bf99b'
        resp.headers['x-amzn-Rmapped-Date'] = '2023-08-17 16:45:43 UTC'
        resp.headers['x-Count'] = '1234'
        resp.headers['Ratelimit-Limit'] = '150'
        resp.headers['Ratelimit-Remaining'] = '98'
        resp.headers['Ratelimit-Reset'] = '1692306166'
        return resp, 201
    else:
        return 'Content-Type not supported!'

if __name__ == "__main__":
    app.run(debug=True)

Detail in here for install dependency and run it.

Bench Vue
  • 5,257
  • 2
  • 10
  • 14