# 400 Bad Request error in c#

**URL:** <https://devforum.zoom.us/t/400-bad-request-error-in-c/133299>\
**Category:** Authentication\
**Tags:** api\
**Created:** [May 28, 2025, 3:48pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299 "2025-05-28T15:48:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cletham](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cletham](https://devforum.zoom.us/u/cletham)\
**Post date:** [May 28, 2025, 3:48pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/1 "2025-05-28T15:48:59Z")

</div>

Hi i am having an issue when trying to get an access token in my program. i am using Visual Studio 2022 and this is the code i have so far:  
i have blanked out the client id and client secret just for security purposes.

```
        HttpClient Authclient = _httpClientFactory.CreateClient();
        Authclient.BaseAddress = new Uri("https://zoom.us/oauth/authorize?response_type=code&client_id= ******** &redirect_uri=");

        var Authparameters = new Dictionary<string, string> { };
        var AuthencodedContent = new FormUrlEncodedContent(Authparameters);

        var Authresponse = await Authclient.PostAsync(Authclient.BaseAddress, AuthencodedContent);
        HttpResponseMessage? AuthRes = await Authclient!.PostAsync(Authclient.BaseAddress, AuthencodedContent);

        var grant_type = "Authorization Code";
        var client_id = " *********";
        var client_secret = " *******";
        var scope = "";

        var AccessToken = "";

        HttpClient client = _httpClientFactory.CreateClient();
        client.BaseAddress = new Uri("https://zoom.us/oauth/token");

        var parameters = new Dictionary<string, string> { { "grant_type", grant_type }, { "client_id", client_id }, { "client_secret", client_secret }, { "scope", scope } };
        var encodedContent = new FormUrlEncodedContent(parameters);

        var response = await client.PostAsync(client.BaseAddress, encodedContent);
        HttpResponseMessage? Res = await client!.PostAsync(client.BaseAddress, encodedContent);

```

i am getting an error with the final final as i am getting an error 400 Bad request.

im not sure whats wrong as i have tested all this in postman and managed to get it to work so not sure ehats causing the issue.

any help would be appreciated.

Thanks

---

<div class="post-metadata">

**Author:** ![alexm](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/alexm/32/67701_2.png) [@alexm](https://devforum.zoom.us/u/alexm)\
**Post date:** [May 29, 2025, 4:13pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/2 "2025-05-29T16:13:58Z")

</div>

For one thing, try `grant_type = "authorization_code"` instead of `"Authorization Code"`

Something about POSTing your client id and secret without encoding it seems very wrong to me; take a look at the C# example (2nd tab) on [this documentation](https://developers.zoom.us/docs/meeting-sdk/windows/pkce/#authenticate-users-with-pkce).

---

<div class="post-metadata">

**Author:** ![desautelsj](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/desautelsj/32/23584_2.png) [@desautelsj](https://devforum.zoom.us/u/desautelsj)\
**Post date:** [May 29, 2025, 11:37pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/3 "2025-05-29T23:37:10Z")

</div>

@cletham You should have a look at [ZoomNet](https://www.nuget.org/packages/ZoomNet) (disclaimer: I’m the author). It’s a .NET client for Zoom’s API. The authentication process is built-in.

---

<div class="post-metadata">

**Author:** ![cletham](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cletham](https://devforum.zoom.us/u/cletham)\
**Post date:** [June 5, 2025, 9:45am UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/4 "2025-06-05T09:45:30Z")

</div>

Hi Alex

Thanks for the reply i made that change but still getting the same error unfortunately

---

<div class="post-metadata">

**Author:** ![cletham](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cletham](https://devforum.zoom.us/u/cletham)\
**Post date:** [June 5, 2025, 9:51am UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/5 "2025-06-05T09:51:01Z")

</div>

Hi Jericho thanks for the reply, i had a look at your documentation and confused as i didn’t get a authorization code when i created my app if this is something you know where to find please let me know.

my app currently is just a general app not a server to server app which i think your documentation focuses on. if there’s a version that looks at general app I’m happy to use that

Thanks,  
Connor

---

<div class="post-metadata">

**Author:** ![desautelsj](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/desautelsj/32/23584_2.png) [@desautelsj](https://devforum.zoom.us/u/desautelsj)\
**Post date:** [June 5, 2025, 11:49am UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/6 "2025-06-05T11:49:14Z")

</div>

> i didn’t get a authorization code when i created my app

When you created the app you were asked to provide the `OAuth redirect URL` like so:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/5/e/5e486cbaef681c8d63c46aec656d51d502026fa8.png)

When someone adds the app to their account, they get redirected to the URL you configured like so:

 ![image](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/8/1/8161762c370035f76506b3966540a4f886b13d49.png)

The code is right there in the URL.

---

<div class="post-metadata">

**Author:** ![cletham](https://avatars.discourse-cdn.com/v4/letter/c/c67d28/32.png) [@cletham](https://devforum.zoom.us/u/cletham)\
**Post date:** [June 5, 2025, 2:15pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/7 "2025-06-05T14:15:19Z")

</div>

in your documentation i don’t see a bit to get that code so are you authenticating before that code or just copying in the code into the code?

---

<div class="post-metadata">

**Author:** ![desautelsj](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/desautelsj/32/23584_2.png) [@desautelsj](https://devforum.zoom.us/u/desautelsj)\
**Post date:** [June 5, 2025, 9:56pm UTC](https://devforum.zoom.us/t/400-bad-request-error-in-c/133299/9 "2025-06-05T21:56:44Z")

</div>

That’s really up to you how you want to do it.

Presumably your redirect URL sends people to a web page that is under your control, where you can write your own code, where you can get the value from the querystring and act appropriately.
