Copied to clipboard

Flag this post as spam?

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


  • Rikhav Shah 5 posts 75 karma points
    Feb 20, 2018 @ 13:33
    Rikhav Shah
    0

    Need a proper way to insert content data in umbraco

    We have successfully get the content using Umbraco Rest API but not able to found document or way to insert content data back using API.

    If anyone can help me provide Umbraco API document which shares knowledge regarding API urls and what type of parameters we need to pass for CRUD operations.

    I had found another way to inserting data i.e using Content Service but I am confused which is better way to perform CRUD operation using API or Service.

    Help me out regarding which is better for CRUD operation. If anyone has any reference to API documentation, I would appreciate if you share with me.

    Thanks, Rikhav Shah

  • David Zweben 266 posts 750 karma points
    Feb 21, 2018 @ 01:11
    David Zweben
    0

    Can you provide some more information about what exactly you're trying to do? Without that, it's hard to provide recommendations.

    • Are you using this project?
    • Do you need to trigger the creation of Umbraco content from an external application?
  • Rikhav Shah 5 posts 75 karma points
    Feb 21, 2018 @ 05:24
    Rikhav Shah
    0

    Thanks David for the reply.

    For reference, we are using the project you had provided the link in first point above.

    Yes, we need to trigger the creation of Umbraco content from an external application.

    We are trying something like this but it is giving 404 Not Found:

        HttpClient client = new HttpClient();
            client.BaseAddress = new Uri("http://localhost:30740/umbraco/rest/v1/content");
    
            client.DefaultRequestHeaders.Add("ContentType", "application/json");
            client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            client.DefaultRequestHeaders.Add("Authorization", "Bearer " + authentication.AccessToken);
    
            var postData = new StringContent(@"{""contentTypeAlias"": ""newsCategory"", ""parentId"": """ + 1057 + @""", ""templateId"": """ + 1053 + @""", ""name"": ""World News API"", ""properties"": { ""category"": ""category property value1"" }}", Encoding.UTF8, "application/json");
    
            HttpResponseMessage response = client.PostAsync("Publish",postData).Result;
    
            string resultJSON = response.Content.ReadAsStringAsync().Result;
    

    I think we are missing something in way to post the data to content API.

    Hope you can help me out on this.

    Thanks, Rikhav Shah

Please Sign in or register to post replies

Write your reply to:

Draft