0

Using Postman I succeeded invoking this api described here https://anypoint.mulesoft.com/exchange/portals/nz-post-group/b8271f09-2ad8-4e1c-b6b1-322c5727d148/nzpost.addresschecker/minor/1.0/pages/Suggest%20Addresses/

but I'm struggling achieving the same with C#.

tried this but didn't work. is this missing any extra header?:

public static async Task<HttpResponseMessage> GetToken()
    {
        var data = new
        {
            client_id = "xxxxxxxxxxxxxxxxxxxxxxxxx",
            client_secret = "xxxxxxxxxxxxxxxxxxxxxx",
            grant_type = "client_credentials"
        };

        var json = JsonConvert.SerializeObject(data);

        var stringContent = new StringContent(json, UnicodeEncoding.UTF8, "application/json"); 

        var client = new HttpClient();
        var response = await client.PostAsync("https://oauth.xxxx.co.nz/as/token.oauth2", stringContent);

        return response;
    }
  • 3
    Does this answer your question? [How do I get an OAuth 2.0 authentication token in C#](https://stackoverflow.com/questions/38494279/how-do-i-get-an-oauth-2-0-authentication-token-in-c-sharp) – mohabbati Aug 19 '21 at 10:36
  • it does answer my question. tried google and the stack overflow search but didn't saw this page, thanks! – BrunoLucasAzure Aug 19 '21 at 10:45

0 Answers0