Skip to main content
added 101 characters in body
Source Link
Lee Ames
  • 349
  • 1
  • 3
  • 14

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

UPDATE:

Here is my latest attempt,it still throws the error.

Body.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");

UPDATE: Content-Type is indeed an invalid header. The API Developers removed it at our request.

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

UPDATE:

Here is my latest attempt,it still throws the error.

Body.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

UPDATE:

Here is my latest attempt,it still throws the error.

Body.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");

UPDATE: Content-Type is indeed an invalid header. The API Developers removed it at our request.

added 159 characters in body
Source Link
Lee Ames
  • 349
  • 1
  • 3
  • 14

I am working with an API service that requires Content-TypeContent-Type to be set to application/json;charset=UTF-8application/json;charset=UTF-8.

If I make a request without the charset=UTF-8charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

UPDATE:

Here is my latest attempt,it still throws the error.

Body.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

UPDATE:

Here is my latest attempt,it still throws the error.

Body.Headers.ContentType = new MediaTypeHeaderValue("application/json;charset=UTF-8");

added 7 characters in body
Source Link
Roman Marusyk
  • 24.8k
  • 27
  • 83
  • 127

I am working with an API service that requires Content-TypeContent-Type to be set to application/json;charset=UTF-8application/json;charset=UTF-8.

If I make a request without the charset=UTF-8charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error: System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error: System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

I am working with an API service that requires Content-Type to be set to application/json;charset=UTF-8.

If I make a request without the charset=UTF-8 I get a 406 - Not Acceptable.

I can make a call through Postman setting the Content-Type as required, but if I use my .Net Http Client I get the error:

System.FormatException: 'The format of value 'application/json;charset=UTF-8' is invalid.'

Is there anyway I can work around this validation and force the Http Client to accept the value?

Source Link
Lee Ames
  • 349
  • 1
  • 3
  • 14
Loading