How to use the contenttype sent by the client on the server

Asked

Viewed 79 times

0

Good afternoon! I am trying to understand the workings of contenttype. As far as I know, I would be telling the server to use the formed JSON UTF8 to correctly encode the data I am sent. contentType: "application/json; charset=utf-8", If I am correct, I still have to know how to use this information. Until now I imagined that it would be including the header.

header('Content-Type: text/html; charset=utf-8');
header('Content-Type: text/json; charset=utf-8');

In that case, if I’m right, there’s some other problem, because I can’t make it work.

Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.
  • What is the difference between this question and the other?

  • If you answer that question, you’ll see the difference. You agreed with my statements I believe, because you deviated from the topic, correct ?

  • Willian didn’t understand what you mean by "you shifted the focus from the topic". The idea of my question was to try to make these questions as specific as possible to be really different questions. While I’m not sure if you understand what CORS is and what that mistake you’re getting means.

  • Sorry. What I want to know is how Contenttype works. I believe it is a guideline for the server to know how to interpret the data it is receiving. Sorry, I don’t know what CORS is.

  • This is a problem that I am facing and I am unable to solve. I am now believing that Content-Type is my solution. My API can receive both XML and JSON.

  • I just don’t know how to identify one or the other.

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.