# HttpClient returns OK, but user not created

**URL:** https://meta.discourse.org/t/httpclient-returns-ok-but-user-not-created/67653
**Category:** Development
**Created:** [8. August 2017 um 14:18 UTC](https://meta.discourse.org/t/httpclient-returns-ok-but-user-not-created/67653 "2017-08-08T14:18:57Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![SwisherSweet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/swishersweet/32/119523_2.png) [@SwisherSweet](https://meta.discourse.org/u/SwisherSweet)
#### Post date: [8. August 2017 um 14:18 UTC](https://meta.discourse.org/t/httpclient-returns-ok-but-user-not-created/67653/1 "2017-08-08T14:18:57Z")

</div>

Hi,

It’s been a while since I’ve worked with the .Net HttpClient and I’m new to the Discourse API. I’m creating a sandbox/playground project to create users in our Discourse instant using the API via .Net.

However, when I call the API, I get a 200 (OK) response, but no user is created:

```
class Program
{
    public class User
    {
        public string name {get;set;}
        public string email {get;set;}
        public string password {get;set;}
        public string username {get;set;}
        public bool active { get; set; }
        
        // will move out later
        public string api_key { get; set; }
        public string api_username { get; set; }
    }

    static void Main()
    {
        RunAsync().Wait();
    }

    static async Task RunAsync()
    {
        HttpClient client = new HttpClient();

        client.BaseAddress = new Uri("https://example.com");
        client.DefaultRequestHeaders.Accept.Clear();
        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
        
        User u = new User {
            name = "test",
            email = "test@example.com",
            password = "testtesttest1!",
            username = "test",
            active = true,
            api_key = "mysecredtapikey",
            api_username = "myadminuser"
        };

        HttpResponseMessage response = await client.PostAsJsonAsync("/users", u);
        response.EnsureSuccessStatusCode();

        // look at the response (
        var x = response;
    }
}

```

The `response` object has a `null` location value, which appears to indicate the user was not created.

Since there are no apparent errors and the response is 200 (OK), I don’t know what I’m doing wrong.

Does anyone have any suggestions on how I might troubleshoot this problem or know what might be wrong with my code?

Thank you.
