title: .NET Core - 415 Unsupported Media Type (HTTP POST)
body: <p>I'm trying to do an HTTP POST to my backend. If I use <code>&quot;Content-Type&quot;: &quot;application/json&quot;</code> I get a CORS issue. The CORS issue is only with the HTTP POST, all the HTTP GETs are working fine. So I set it to <code>&quot;Content-Type&quot;: &quot;text/plain&quot;</code> and it seems to solve the issue. However, now I am getting the <code>415 Unsupported Media Type</code> error when doing the HTTP POST. This is my config:</p>
  <p><strong>Axios</strong></p>
  <pre><code>import { AxiosRequestConfig } from &quot;axios&quot;;
  
  export const axiosRequestConfiguration: AxiosRequestConfig = {
    baseURL: process.env.REACT_APP_API_BASE_URL,
    responseType: &quot;json&quot;,
    withCredentials: true,
    headers: {
      //&quot;Content-Type&quot;: &quot;application/json&quot;,
       &quot;Content-Type&quot;: &quot;text/plain&quot;,
    },
  };
  </code></pre>
  <p><strong>.NET Core</strong></p>
  <pre><code>public void ConfigureServices(IServiceCollection services)
  {
      var origins = Configuration.GetSection(&quot;AllowSpecificOrigins&quot;).GetChildren().Select(o =&gt; o.Value).ToArray();
  
      services.AddControllers().AddNewtonsoftJson();
  
      services.AddSwaggerGen(c =&gt;
      {
          c.SwaggerDoc(&quot;v1&quot;, new OpenApiInfo
          {
              Version = &quot;v1&quot;,
              Title = &quot;Payload View API&quot;,
          });
      });
  
      services.AddCors(options =&gt;
      {
          options.AddPolicy(name: MyAllowSpecificOrigins,
              builder =&gt;
              {
                  builder
                      .WithOrigins(origins)
                      .AllowAnyHeader()
                      .AllowCredentials()
                      .AllowAnyMethod()
                      .WithExposedHeaders(&quot;Authorization&quot;, &quot;WWW-Authenticate&quot;);
              });
      });
  </code></pre>
  <p><strong>Endpoint</strong></p>
  <pre><code>[HttpPost]
  public IActionResult SubmitFeedback([FromBody] Feedback feedback)
  {
      if (feedback == null) return StatusCode(StatusCodes.Status400BadRequest);
  
      try
      {
          _feedbackService.SubmitFeedback(feedback);
  
          return StatusCode(StatusCodes.Status201Created);
      }
      catch (Exception ex)
      {
          _logger.LogError(ex.StackTrace);
          return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
      }
  }
  </code></pre>