Iam trying to Login into a application using post API and C#
The json is formatted like this:
jsonbody = {"grant_type": "password","tenantName":"<alphanumeric Variable>","userName":"<alphanumeric Variable>","password":"<alphanumeric Variable>"}" ;
I am using this code for the login API:
var request = HttpWebRequest.Create(url);
var byteData = Encoding.ASCII.GetBytes(jsonbody);
request.ContentType = "application / x - www - form - urlencoded";
request.Method = "POST";
try
{
using (var stream = request.GetRequestStream())
{
stream.Write(byteData, 0, byteData.Length);
}
var response = (HttpWebResponse)request.GetResponse();
}
catch ()
{
}
I have confirmed that the Url I am attempting to post to is correct and the credentials that I am using is correct scope. What am I missing?