C# Console Rest API header payload -


i need access portal controlled bearer authentication. client needs obtain authentication token add each request

url ~/token method post content-type application/x-www-form-urlencoded payload grant_type=password&username=username&password=password

**how add payload includes grant type , username , password code **

so far code follows :

using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; using system.net;   namespace consolerestclient  {      class program     {     static void main(string[] args)     {         string uri = "https://token";         webrequest request = webrequest.create(uri);         request.method = "post";         request.contenttype = "application/x-www-form-urlencoded";         }      }`    } 

you should sending request content type "application/json" , put requested login variable on body. give idea:

  • headers:

    content-type:application/json

  • body:

    { "username": "myusername", "password": "mypassword" }


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -