コード例 #1
0
        public Boolean CheckUpdatedPost(int postId)
        {
            client  = new RestClient(url + "/posts/" + postId);
            request = new RestRequest("GET");

            response = client.Execute(request);
            var postModel = PostModel.FromJson(response.Content);

            return(postModel.Title == titlePostUpdated);
        }
コード例 #2
0
        public int RegistryPost()
        {
            client  = new RestClient(url + "/posts");
            request = new RestRequest(Method.POST);

            request.AddHeader("Content-type", "application/json; charset=UTF-8");

            PostModel newPost = new PostModel();

            newPost.Title  = "new post - gabriela lima";
            newPost.UserId = 1;
            newPost.Body   = "This is a new post registred by Gabriela Lima";

            request.AddParameter("undefined", newPost.ToJson(), ParameterType.RequestBody);

            response = client.Execute(request);
            var postModel = PostModel.FromJson(response.Content);

            return(postModel.Id);
        }