Question: I'm using DotNetOpenAuth and attempting to post a JSON object to a server.

The server is throwing a WebContentType = Raw error.

```
Authorization: OAuth
oauth_token="V9vVXD51ehUU6WmY%2FQ41qta0RfY%3D",oauth_consumer_key="CHiawRiAb299cOas",oauth_nonce="BBTM4csg",oauth_signature_method="HMAC-SHA1",oauth_signature="KZJZvT630f2KenB9l9tqSLI%2FfHA%3D",oauth_version="1.0",oauth_timestamp="1306870331"
Content-Type: application/x-www-form-urlencoded; charset=utf-8 
User-Agent: DotNetOpenAuth/3.4.6.10357

```

I guess I'm really looking for an example on how to do this? Or a Url to a sample?

I'm currently trying

```
WebRequest httpRequest = consumer.
    PrepareAuthorizedRequest(endpoint, AccessToken, para);
httpRequest.ContentType = "application/json";
WebResponse webResponse = httpRequest.GetResponse();

```

Answer: 
Originally [answered by iain](https://stackoverflow.com/revisions/6192644/2):

Okay, I have managed to solve this. The problem that I have found is I was invoking `PrepareAuthorizedRequest` from the `ConsumerBase`. The content type is then not honoured after this and it is always marked as `x-www-form-urlencoded`. To work around this I called `PrepareAuthorizedRequest` as normal then created a new HttpWebRequest and copied across the OAuth Authorization header.

```
HttpWebRequest httpRequest = consumer.
    PrepareAuthorizedRequest(endpoint, AccessToken);

HttpWebRequest httpWebRequest = (HttpWebRequest)
    WebRequest.Create(serviceBase + "/Edit/6363241");

foreach (string headerKey in httpRequest.Headers.AllKeys)
    httpWebRequest.Headers.Add(headerKey, httpRequest.Headers[headerKey]);

httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";

using (Stream requestStream = httpWebRequest.GetRequestStream())
{
    byte[] bytes = Encoding.UTF8.GetBytes(test22);
    requestStream.Write(bytes, 0, bytes.Length);
}

WebResponse webResponse = httpWebRequest.GetResponse();

string responseContent = new StreamReader(webResponse.GetResponseStream()).
    ReadToEnd();

```
You need to set the `Content-Length` header via the `httpRequest.ContentLength` property *prior to getting the request stream*.

Also, while you already had it, I searched for hours trying figure out what I was missing, which was the `HttpDeliveryMethods.AuthorizationHeaderRequest` in the `endpoint` declaration.

```
string url = serviceBase + "/Booking/6363241";
HttpDeliveryMethods methods = HttpDeliveryMethods.PostRequest | HttpDeliveryMethods.AuthorizationHeaderRequest;
MessageReceivingEndpoint endpoint = new MessageReceivingEndpoint(url, methods);
WebRequest httpRequest = consumer.PrepareAuthorizedRequest(endpoint, AccessToken);
httpRequest.ContentType = "application/json";

byte[] bytes = Encoding.UTF8.GetBytes(test22);
httpRequest.ContentLength = bytes.Length;

using (Stream requestStream = httpRequest.GetRequestStream())
{
    requestStream.Write(bytes, 0, bytes.Length);
}

string responseContent;
using (HttpWebResposne response = (HttpWebResponse)httpRequest.GetResponseStream())
using (StreamReader reader = new StreamReader(response))
{
    responseContent = reader.ReadToEnd();
}

```