Start a new topic

Tutorials for C# .Net

 Scenario is,

Im new to Kinvey,

I need some tutorials for Specific C# to use with kinvey so that I can CRUD operations on REST API.


Zaid Mirza

Hi Zaid,

Can you tell me more about your use case:

  • What kind of application are you planning to build using C# and Kinvey?
  • Which platforms are you targeting?

I will be able to help you out once I know about your use case.



Kinvey Support

Hi Wani,

Actually, I have not started any production mode development yet. I am just trying to learn Kinvey Rest API using in C#.

I made a test use case:

Adding Books and their Editors Information on Kinvey
Books and Editors have one-to-many relation (One Book can have many Editors).

When I posted this thread, at that time I did not know how to Call Rest API CRUD requests from C#. But After Some Struggle,I can now CRUD on Kinvey using C#
below is Code sample For Post Request.

                Books st = new Books();
                st.BookName = "C#";
                st.Title = "Intro to C#";
                Editors ed = new Editors();
                ed.EditorName = "Junaid";
                ed.EditorAge = 28;
                Editors ed1 = new Editors();
                ed.EditorName = "Obaid";
                ed.EditorAge = 27;
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(Books));
                MemoryStream mem = new MemoryStream();
                ser.WriteObject(mem, st);
                // string data = Encoding.UTF8.GetString(mem.ToArray(), 0, (int)mem.Length);
                WebClient webClient = new WebClient();
                webClient.Headers["Content-type"] = "application/json";
                webClient.Encoding = Encoding.UTF8;
                byte[] credentialBuffer = new UTF8Encoding().GetBytes("zaidmirza" + ":" + "zaidmirza");
                string authToken = Convert.ToBase64String(credentialBuffer);
                string authHeaderValue = string.Format(System.Globalization.CultureInfo.InvariantCulture, "Basic {0}", authToken);
                webClient.Headers["Authorization"] = authHeaderValue;
                byte[] data = webClient.UploadData("", "POST", mem.ToArray());
                MemoryStream stream = new MemoryStream(data);
                DataContractJsonSerializer obj = new DataContractJsonSerializer(typeof(Books));
                Books result = obj.ReadObject(stream) as Books;

 I made two DataContracts  for Json Serialization and Deserialization in C# named "Books","Editors".
I made Editors as ICollection in Books Contract as you can see below


namespace KinveyUD
    class Books
        public Books()
            this.Editors = new HashSet<Editors>();
        public string BookName { get; set; }
        public string Title { get; set; }
        public string _id { get; set; }
        [DataMember(EmitDefaultValue = false)]
        public virtual ICollection<Editors> Editors { get; set; }

 Now My problem is that. I want to Insert References on Kinvey from C#.
I made Books Collection and Editor Collection on kinvey App.
But confused how to add one Book with many Editiors.
How KinveyRef Objects to miantain ?

As you can see in above POST request sample code. Im adding Editors in Books Object then Posting Books on Kinvey. In this way , Editors are not being saved on Editors Collection on kinvey but Editors are being saved as array value in Books Record

see below image


But I want to maintain Kinvey Standard methods for references by using _type,KinveyRef,_Id etc
Please tell me how to do that



This documentation link: covers a similar scenario of books collection with reference to authors and publishers. This should set you up to use Kinvey references effectively.

To sum it up in one sentence, you need to save editors first and then save the book object with KinveyRef array containing editor ids.

Let me know if you get face any issues with the implementation.



Kinvey Support

Hi Wani,

Do you mean I have to POST parent entity first then childs? if yes then I have to set KinvevRef,_type,_collection attributes from front end in POST request preparation of child records?


hi Zaid Mirza,

did u get something about access kinvey in C# application ?

Hi Gayan,

Yes I used WebClient or WebRequest to make a REST calls. I was looking for code sample for you in my directory but it is missing. We changed our backend planning from kinvey to firebase cloud due to some other reason. But you can use WebClient or WebRequest classes in C# to make any REST calls with GET,POST,PUT,DELETE.... Methods


in firebase can be possible for storing and retrieving bitmap images

Hi Gayan,

You can see sample code for kinvey in c# in above comments and you can save any type of image at any cloud by converting them in bytes string like "YyauuuUYw%rRARrRRrAttatttRrTYYQyqtqtTQttq........" you can use 64base or any other method to convert


ok, i planing move on kinvey for Windows dektop application and mobile application. so it's possible right  ?

Kinvey is good but it dont support deployment yet, you have to use third party to deploy your mob app


Login or Signup to post a comment