Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hardik Mehta 12 posts 83 karma points
    Feb 21, 2018 @ 09:25
    Hardik Mehta
    0

    How to publish content using umbraco rest api

    I am trying to publish content using this code but it not works,

    Any one have idea how to publish content using umbraco rest api.

            var httpClient = new HttpClient();
    
            httpClient.BaseAddress = new Uri("http://localhost:30740/umbraco/rest/v1/content/1061/publish");
    
            httpClient.DefaultRequestHeaders.Accept.Clear();
    
            httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
    
            httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + authentication.AccessToken);
    
            HttpResponseMessage response = httpClient.PutAsync("Publish", new StringContent(@"{""id"": ""1061""}", Encoding.UTF8, "application/json")).Result;
    
            var jsonObject = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result.ToString());
    
            var jsonString = response.Content.ReadAsStringAsync();
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies