Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mh71's avatar
Level 1

What is the "Accept : application/json" header?

I've made it all the way down to "Validation and Exception Handling" on the sample code https://code.tutsplus.com/tutorials/build-a-react-app-with-laravel-restful-backend-part-1-laravel-5-api--cms-29442

The section in the tutorial above that line ends with "Open up POSTMAN and the endpoints for the product should be working. Make sure you have the Accept : application/json header enabled."

I'd never heard of POSTMAN. So I downloaded it, and there's a Send button on it.

I don't know where to find an "Accept : application/json header."

I don't know what endpoints are, and I don't know how to test the tutorial Part 1 code on this sample to see if I have even put it together correctly before proceeding to Part 2.

(I'm using Laravel 8.)

(Also, I don't know if this is significant or not diagnostically, but on URL localhost:8000/api/products, I do see all of the rows of the products table, output in plaintext.)

0 likes
7 replies
martinbean's avatar

@mh71 When making a request, it tells you server that you’ll only accept a JSON response. Otherwise, the server will return what it wants (and usually HTML by default).

mh71's avatar
Level 1

Thank you all for your help.

Is "Accept : application/json" a statement that accompanies a URL string? Like is it attached somehow to where I write "localhost:8000/api/products"?

bugsysha's avatar

Think of it as additional bit of information that you can send to the server.

mh71's avatar
Level 1

If "Accept : application/json" is a statement that I write into a file, I don't understand where to write it.

I tried writing it on the next line directly under [left arrow]!doctype html[right arrow] near the top of the page and it didn't work.

I have no idea where to put this. And when I do research only, everything is talking only in the abstract. When I even try to look up images of "Accept : application/json" I just get the aftermath: https://duckduckgo.com/?q=%22Accept+%3A+application%2Fjson%22&iax=images&ia=images

Can somebody please help me with where to write the string "Accept : application/json" if that's what's called for in the tutorial? Because it doesn't specify where or how.

jlrdw's avatar

See the chapters in laravel on requests and responses.

Please or to participate in this conversation.