Error E0000003 when Getting Session Cookie in .Net

I’m very new to Okta (< 1 week) and I’m trying to incorporate Okta into an existing MVC.Net application that does not have any current authentication mechanism.

I’m currently trying to use the Okta Authentication API and the Session API – although I’m open to other ways if there’s a better/easier way.

I can authenticate a username / password and I get back a valid sessionToken but I cannot seem to create a session with that token.

If I try the Session API (below), it works in Postman but I get back an error E0000003 using the code below.

        var client = new RestClient(baseUri + "/api/v1/sessions?additionalFields=cookieToken");
        var request = new RestRequest(Method.POST);
        request.RequestFormat = DataFormat.Json;
        request.AddHeader("Authorization", apiToken);
        request.AddHeader("Content-Type", "application/json");
        request.AddHeader("Accept", "application/json");

        var str = String.Format("{{ \"sessionToken\" : \"{0}\" }}", sessionToken);
        request.AddJsonBody(str);
        var resp = client.Execute(request);

What am I missing?

I’m unsure. Is it possible to debug the request to see what you are sending? E0000003 usually means that the body of the request is malformed.

@aaronshelby Is there any message that comes back with that E0…03 error?

In trying to provide answers to your question, I discovered the error. I was passing the serialized JSON string into the AddJsonBody() method. This caused it to escape the escape characters (\" for example) which resulted in malformed JSON. It turns out that AddJsonBody was expecting an object to serialize.

Converting my token to an anonymous object and then passing that object to the AddJsonBody method worked.

1 Like

Makes sense, glad you got it figured out!