I am trying to create JWT for authenticating REST api. Please find my code below.
private static string getJWT()
{
var client = new RestClient("https://itsmtest-app.XXXXXX.com/api/jwt/login");
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
request.AddParameter("username", "testuser",ParameterType.RequestBody);
request.AddParameter("password", "Passw0rd",ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
Console.WriteLine(response.Content);
return response.Content;
}
I am getting an error. please find response.Content as below. But the rest call working fine in postman even I copied the code postman.
Error 406 Not Acceptable
HTTP ERROR 406 Problem accessing /api/jwt/login. Reason:Not Acceptable
HTTP ERROR: 500
Problem accessing /api/jwt/login. Reason:
– girish May 13 '20 at 14:31