title: Posting JSON data using HttpClient
body: <p>I am trying to create a service hook subscription in Visual Studio Team Services, previously Visual Studio Online, programatically. When a project is created in Team Services, service hook will be automatically created. Following is my code for 'workitem created' web hook: </p>
  
  <pre><code>using (HttpClient client = new HttpClient())
                  {
                      client.DefaultRequestHeaders.Accept.Add(
                          new MediaTypeWithQualityHeaderValue("application/json"));
  
                      client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                         Convert.ToBase64String(
                             System.Text.ASCIIEncoding.ASCII.GetBytes(
                                 string.Format("{0}:{1}", username, password))));
  
                      var request = new 
                      {
                          publisherId = "tfs",
                          eventType= " workitem.created",
                          resourceVersion= "1.0",
                          consumerId= "webHooks",
                          consumerActionId= "httpRequest",
                          publisherInputs= new {      
                              projectId= "test123",
                          }, 
                          consumerInputs= new {
                              url = "https://mydomain/api/ServiceHook/SaveWorkItem"
                          }
                      };
  
  
                      var response = client.PostAsync("https://mydomain/DefaultCollection/_apis/hooks/subscriptions",
                          new StringContent(JsonConvert.SerializeObject(request).ToString(),
                              Encoding.UTF8, "application/json"))
                              .Result;
  
                      if (response.IsSuccessStatusCode)
                      {
                          dynamic content = JsonConvert.DeserializeObject(
                              response.Content.ReadAsStringAsync()
                              .Result);
  
  
                          // Access variables from the returned JSON object
                          var appHref = content.links.applications.href;
                      }
                  }
  </code></pre>
  
  <p>while running this code, I got the following error: <code>Unexpected character encountered while parsing value: &lt;. Path '',</code>.</p>
  
  <p>Can any one please help me to solve this?<br>
  Thanks in advance. 
  Stack Trace is:  </p>
  
  <pre><code>at Newtonsoft.Json.JsonTextReader.ParseValue()
     at Newtonsoft.Json.JsonTextReader.Read()
     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadForType(JsonReader reader, JsonContract contract, Boolean hasConverter)
     at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
     at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
     at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
     at Newtonsoft.Json.JsonConvert.DeserializeObject(String value)
     at TestApplication.Program.&lt;SetServiceHook&gt;d__1.MoveNext() in C:\Users\Administrator\Documents\Visual Studio 2015\Projects\TestApplication\TestApplication\Program.cs:line 94
  </code></pre>