Consuming Drupal RestApi with c#

前端 未结 3 906
一生所求
一生所求 2021-01-24 11:49

I am working to consume Drupal Rest Api using c#. I am using drupal 7.5 and utilising it\'s rest services/api following various resources.

I have been successful with go

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 12:17

    I used following to login to drupal

    var client = new RestClient("drupalsitename/user/login");
    var request = new RestRequest(Method.POST);
    request.AddHeader("cache-control", "no-cache");
    request.AddHeader("content-type", "application/json");
    request.AddHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:48.0) Gecko/20100101 Firefox/48.0");
    request.AddParameter("application/json", "{\"name\":\"username\",\n\"pass\":\"password\"}", ParameterType.RequestBody);
    IRestResponse response = client.Execute(request);
    

    This will provide you with necessary session and token info and then basically you can use those information to make the post, similar to that I have written in the question

提交回复
热议问题