简体   繁体   中英

REST API: How to provide http request header details

Testing with the postman app

I am making a request (GET) to fetch data from the server since the endpoints are authenticated, I'm providing the token value in the headers option. The above request works in the postman app. I'm building a REST API for the first time so I don't know how to define the header details (token value) while accessing the endpoint via browser.

I tried it in this format: http://ip-add:port/endpoint?token=value but it says unauthorized access. Here is a snippet of token authentication function:

REST API - token authentication function

I don't know how to define the header details (token value) while accessing the endpoint via browser.

This might vary accross browser, for example in Firefox, open developer tools (hit F12), go to network tab, find new request (plus icon) select verb (GET is default), provide URL and headers (name-value pairs) you want then hit send.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM