C#

This tutorial provides you with a step-by-step walkthrough on how to interact with the IoT Connect 365 API

This is not a production-ready application. Please take your time to make it meet your business requirements and production standards.

Steps

Code

keyboard_arrow_down
1
2
3
4
5
6
7
8
{
    // _Step_1
    "applicationToken": "",
    "baseUrl": "https://sapiotconnect365.sapdigitalinterconnect.com",
    "setProxy": false,
    "proxyHost": "10.125.30.15",
    "proxyPort": "8080"
}
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
using System;
using System.Collections.Generic;
using System.Net;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using RestSharp;

namespace iot
{
    public class IOTJson
    {
        private static IOTJson instance;
        private static String applicationToken;
        private static String baseUrl;
        private static String token;
        private static JObject properties;

        public static IOTJson Instance { get => instance; set => instance = value; }
        public static string ApplicationToken { get => applicationToken; set => applicationToken = value; }
        public static string BaseUrl { get => baseUrl; set => baseUrl = value; }
        public static string Token { get => token; set => token = value; }
        public static JObject Properties { get => properties; set => properties = value; }

        public IOTJson(JObject properties)
        {
            Properties = properties;
            baseUrl = properties.GetValue("baseUrl").ToString();
            applicationToken = properties.GetValue("applicationToken").ToString();
        }

        public IOTJson() { }

        public static IOTJson GetInstance()
        {
            if (instance == null)
                instance = new IOTJson();
            return instance;
        }

        // _Step_2
        public static void Authenticate()
        {
            Object payload = new {
                application_token = ApplicationToken
            };
            String payloadData = JsonConvert.SerializeObject(payload);

            String authenticationUrl = BaseUrl + "/api/v1/authenticate";

            RestClient client = new RestClient(authenticationUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.POST);
            request.AddHeader("content-type", "application/json");
            request.AddParameter("application/json", payloadData, ParameterType.RequestBody);
            Console.WriteLine("Client Data: " + payload.ToString());

            IRestResponse<Dictionary<String, String>> response = client.Execute<Dictionary<String, String>>(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                throw new AuthenticationException("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
                Console.WriteLine("");
                response.Data.TryGetValue("auth_token", out token);
                Console.WriteLine("Token: " + token);
            }
            Console.WriteLine(" ");
        }

        public static void GetRequest(String name, String param)
        {
            String requestUrl = BaseUrl + "/api/v1/" + name + param;

            RestClient client = new RestClient(requestUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.GET);
            request.AddHeader("accept", "application/json");
            request.AddHeader("Authorization", "Bearer " + token);
            Console.WriteLine(String.Format("Sending Data: {0} to {1}", request.Method.ToString(), requestUrl));

            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                Console.WriteLine("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
            }
            Console.WriteLine(" ");
        }

        public static void DeleteRequest(String name, String param)
        {
            String requestUrl = BaseUrl + "/api/v1/" + name + "/" + param;
            Console.WriteLine("URI: " + requestUrl);

            RestClient client = new RestClient(requestUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.DELETE);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Bearer " + token);
            Console.WriteLine(String.Format("Sending Data: {0} to {1}", request.Method.ToString(), requestUrl));

            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                Console.WriteLine("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
            }
            Console.WriteLine(" ");
        }

        public static void PatchRequest(String name, String param, Dictionary<String, String> NVPair)
        {
            String json = "{\n";

            foreach (KeyValuePair<String, String> entry in NVPair) {
                json += ("\"" + entry.Key + "\": " + entry.Value + ",");
            }
            json = json.Remove(json.Length - 1, 1);
            json += "\n}";


            String requestUrl = BaseUrl + "/api/v1/" + name + "/" + param;
            Console.WriteLine("URI: " + requestUrl);

            RestClient client = new RestClient(requestUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.PATCH);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Bearer " + token);
            request.AddParameter("application/json", json, ParameterType.RequestBody);
            Console.WriteLine(String.Format("Sending Data: {0} to {1}", request.Method.ToString(), requestUrl));

            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                Console.WriteLine("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
            }
            Console.WriteLine(" ");
        }

        public static void PatchRequest(String name, String param)
        {
            String requestUrl = BaseUrl + "/api/v1/" + name + "/" + param;
            Console.WriteLine("URI: " + requestUrl);

            RestClient client = new RestClient(requestUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.PATCH);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Bearer " + token);
            request.AddParameter("application/json", "", ParameterType.RequestBody);
            Console.WriteLine(String.Format("Sending Data: {0} to {1}", request.Method.ToString(), requestUrl));

            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                Console.WriteLine("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
            }
            Console.WriteLine(" ");
        }

        public static void PostRequest(String name, Dictionary<String, String> NVPair)
        {
            String requestUrl = BaseUrl + "/api/v1/" + name;
            Console.WriteLine("URI: " + requestUrl);

            RestClient client = new RestClient(requestUrl);

            if (properties.GetValue("setProxy").Value<Boolean>()) {
                client.Proxy = new WebProxy("http://" + properties.GetValue("proxyHost").ToString() + ":" + properties.GetValue("proxyPort").ToString());
                client.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                Console.WriteLine("Using Proxy...");
            }
            RestRequest request = new RestRequest(Method.POST);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("Authorization", "Bearer " + token);
            request.AddParameter("application/json", "", ParameterType.RequestBody);
            Console.WriteLine(String.Format("Sending Data: {0} to {1}", request.Method.ToString(), requestUrl));

            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.OK) {
                Console.WriteLine("Failed: HTTP error code " + response.StatusCode.ToString() + ";\n" + response.StatusDescription);
            } else {
                Console.WriteLine("Response from server: ");
                Console.WriteLine(JValue.Parse(response.Content).ToString(Formatting.Indented));
                Console.WriteLine("Headers:");
                foreach (Parameter header in response.Headers) {
                    Console.WriteLine("Name: " + header.Name + ", Value: " + header.Value);
                }
            }
            Console.WriteLine(" ");
        }
    }

    public class AuthenticationException : Exception
    {
        public AuthenticationException()
        {

        }

        public AuthenticationException(String message) : base(String.Format("Authentication Error, {0}", message))
        {

        }
    }
}
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using Newtonsoft.Json.Linq;

namespace iot
{
    public class IOTConsole
    {
        public JObject properties;

        public IOTConsole()
        {
            properties = JObject.Parse(File.ReadAllText(@"../../properties.json"));
        }

        public void StartConsole()
        {
            IOTJson.Properties = properties;
            IOTJson.BaseUrl = properties.GetValue("baseUrl").ToString();
            IOTJson.ApplicationToken = properties.GetValue("applicationToken").ToString();
            Boolean loop = true;

            // _Step_3
            while (loop) {
                Console.WriteLine("---------Main Menu--------");
                Console.WriteLine("1. Endpoint");
                Console.WriteLine("2. SIM");
                Console.WriteLine("3. Events");
                Console.WriteLine("4. ServiceLookup");
                Console.WriteLine("5. Exit");
                Console.WriteLine("");
                Console.Write("Enter your choice: ");
                String choice = Console.ReadLine();

                if (choice.Trim().Equals("1")) {
                    EndpointOp();
                } else if (choice.Trim().Equals("2")) {
                    SimOp();
                } else if (choice.Trim().Equals("3")) {
                    EventOp();
                } else if (choice.Trim().Equals("4")) {
                    LookupOp();
                } else if (choice.Trim().Equals("5")) {
                    loop = false;
                }
            }
        }

        // _Step_4
        private static void EndpointOp()
        {
            try {
                Boolean loop = true;
                while (loop) {
                    Console.WriteLine("------------Endpoint---------------");
                    Console.WriteLine("1. Create Endpoint");
                    Console.WriteLine("2. Delete Endpoint By ID");
                    Console.WriteLine("3. Retrive Endpoint By ID");
                    Console.WriteLine("4. Retrive Endpoint By Name");
                    Console.WriteLine("5. Update Endpoint By ID");
                    Console.WriteLine("6. Go to Main Menu");
                    Console.WriteLine("");
                    Console.Write("Endpoint | Enter your choice: ");

                    String choice = Console.ReadLine();

                    if (IOTJson.Token == null) {
                        IOTJson.Authenticate();
                    }

                    if (choice.Trim().Equals("1")) {
                        Dictionary<String, String> NVPare = new Dictionary<String, String>();

                        Console.Write("Enter the name (required): ");
                        String name = Console.ReadLine();
                        name = makeValue(name, false);
                        if (!String.IsNullOrWhiteSpace(name)) {
                            NVPare.Add("name", name);
                        }

                        Console.Write("Enter the status (required) 0 Enable, 1 Disable: ");

                        String status = Console.ReadLine();
                        if (!String.IsNullOrWhiteSpace(status)) {
                            status = "{ \"id\":" + status + " }";
                            NVPare.Add("status", status);
                        }

                        Console.Write("Enter the service profile (required): ");

                        String service_profile = Console.ReadLine();
                        service_profile = makeValue(service_profile, true);
                        if (!String.IsNullOrWhiteSpace(service_profile)) {
                            NVPare.Add("service_profile", service_profile);
                        }

                        Console.Write("Enter the tariff profile (required): ");

                        String tariff_profile = Console.ReadLine();
                        tariff_profile = makeValue(tariff_profile, true);

                        if (!String.IsNullOrWhiteSpace(tariff_profile)) {
                            NVPare.Add("tariff_profile", tariff_profile);
                        }

                        Console.Write("Enter the SIM ID: ");

                        String sim = Console.ReadLine();
                        sim = makeValue(sim, true);
                        if (!String.IsNullOrWhiteSpace(sim)) {
                            NVPare.Add("sim", sim);
                        }
                        IOTJson.PostRequest("endpoint", NVPare);

                    } else if (choice.Trim().Equals("2")) {

                        Console.Write("Enter the EndpointID: ");

                        choice = Console.ReadLine();
                        IOTJson.DeleteRequest("endpoint", choice);

                    } else if (choice.Trim().Equals("3")) {
                        Console.Write("Enter the EndpointID: ");

                        choice = Console.ReadLine();
                        IOTJson.GetRequest("endpoint/", choice);

                    } else if (choice.Trim().Equals("4")) {
                        Console.Write("Enter the Endpoint Name: ");

                        String name = Console.ReadLine();
                        IOTJson.GetRequest("endpoint?", "q=name:" + HttpUtility.UrlEncode(name));

                    } else if (choice.Trim().Equals("5")) {
                        Console.Write("Enter the Endpoint ID: ");

                        String endpointID = Console.ReadLine();

                        Dictionary<String, String> NVPare = new Dictionary<String, String>();
                        Console.Write("Enter the name: ");

                        String name = Console.ReadLine();

                        if (name != null) {
                            NVPare.Add("name", name);
                        }

                        Console.Write("Enter the status (0: Enable, 1: Disalbe): ");

                        String status = Console.ReadLine();
                        if (!String.IsNullOrWhiteSpace(status)) {
                            status = "{ \"id\":" + status + " }";
                            NVPare.Add("status", status);
                        }
                        Console.Write("Enter the sevice profile ");

                        String service_profile = Console.ReadLine();
                        service_profile = makeValue(service_profile, true);
                        if (service_profile != null) {
                            NVPare.Add("service_profile", service_profile);
                        }
                        Console.Write("Enter the tariff profile: ");

                        String tariff_profile = Console.ReadLine();
                        tariff_profile = makeValue(tariff_profile, true);
                        if (tariff_profile != null) {
                            NVPare.Add("tariff_profile", tariff_profile);
                        }

                        Console.Write("Enter the SIM ID: ");

                        String sim = Console.ReadLine();
                        sim = makeValue(sim, true);
                        if (sim != null) {
                            NVPare.Add("sim", sim);
                        }

                        IOTJson.PatchRequest("endpoint", endpointID, NVPare);
                    } else if (choice.Trim().Equals("6")) {
                        loop = false;
                    }
                }
            } catch (AuthenticationException ex) {
                Console.WriteLine(ex.Message);
            }


        }

        private static void SimOp()
        {
            try {
                Boolean loop = true;

                while (loop) {
                    Console.WriteLine("------------SIM---------------");
                    Console.WriteLine("1. Retrive SIM By ICCID");
                    Console.WriteLine("2. Retrive SIM By ID");
                    Console.WriteLine("3. Activate SIM By ID");
                    Console.WriteLine("4. Suspend SIM By ID");
                    Console.WriteLine("5. Register SIM");
                    Console.WriteLine("6. Go to Main Menu");
                    Console.WriteLine("");
                    Console.Write("SIM | Enter your choice: ");

                    String choice = Console.ReadLine();

                    if (IOTJson.Token == null) {
                        IOTJson.Authenticate();
                    }

                    if (choice.Trim().Equals("1")) {
                        Console.Write("Enter the iccid# ");
                        String iccid = Console.ReadLine();
                        IOTJson.GetRequest("sim?", "q=iccid:" + iccid);
                    } else if (choice.Trim().Equals("2")) {
                        Console.Write("Enter the SIM ID:");
                        choice = Console.ReadLine();
                        IOTJson.GetRequest("sim/", choice);
                    } else if (choice.Trim().Equals("3")) {
                        Console.Write("Enter the SIM ID: ");
                        choice = Console.ReadLine();
                        Dictionary<String, String> NVPair = new Dictionary<String, String>();
                        String returnValue = "{ \"id\": 1 }";
                        NVPair.Add("status", returnValue);
                        IOTJson.PatchRequest("sim", choice, NVPair);
                    } else if (choice.Trim().Equals("4")) {
                        Console.Write("Enter the SIM ID: ");
                        choice = Console.ReadLine();
                        Dictionary<String, String> NVPair = new Dictionary<String, String>();
                        String returnValue = "{ \"id\": 2 }";
                        NVPair.Add("status", returnValue);
                        IOTJson.PatchRequest("sim", choice, NVPair);
                    } else if (choice.Trim().Equals("5")) {
                        Console.Write("Enter the BIC Code without hyphen: ");
                        choice = Console.ReadLine();
                        IOTJson.PatchRequest("sim_batch/bic/", choice);
                    } else if (choice.Trim().Equals("6")) {
                        loop = false;
                    }
                }
            } catch (AuthenticationException ex) {
                Console.WriteLine(ex.Message);
            }
        }

        private static void EventOp()
        {
            try {
                Boolean loop = true;
                while (loop) {
                    Console.WriteLine("----------------Event--------------------");
                    Console.WriteLine("1. Retrive Events By Endpoint");
                    Console.WriteLine("2. Retrive Events By ICCID");
                    Console.WriteLine("3. Retrive EventTypes");
                    Console.WriteLine("4. Retrive Events By Type");
                    Console.WriteLine("5. Retrive Event By Event ID");
                    Console.WriteLine("6. Go to Main Menu");
                    Console.WriteLine("");
                    Console.Write("Event | Enter your choice: ");

                    String choice = Console.ReadLine();

                    if (IOTJson.Token == null) {
                        IOTJson.Authenticate();
                    }

                    if (choice.Trim().Equals("1")) {
                        Console.Write("Enter the Endpoint Name: ");
                        String name = Console.ReadLine();
                        IOTJson.GetRequest("event?", "q=endpoint:" + HttpUtility.UrlEncode(name));
                    } else if (choice.Trim().Equals("2")) {
                        Console.Write("Enter the ICCID: ");
                        String iccid = Console.ReadLine();
                        IOTJson.GetRequest("event?", "q=iccid:" + iccid);
                    } else if (choice.Trim().Equals("3")) {
                        IOTJson.GetRequest("event/", "type");
                    } else if (choice.Trim().Equals("4")) {
                        Console.Write("Enter the EventType (0 - 10): ");
                        String type = Console.ReadLine();
                        IOTJson.GetRequest("event?", "q=type:" + type);
                    } else if (choice.Trim().Equals("5")) {
                        Console.Write("Enter the EventID: ");
                        String id = Console.ReadLine();
                        IOTJson.GetRequest("event?", "q=id:" + id);
                    } else if (choice.Trim().Equals("6")) {
                        loop = false;
                    }
                }
            } catch (AuthenticationException ex) {
                Console.WriteLine(ex.Message);
            }
        }

        private static void LookupOp()
        {
            try {


                Boolean loop = true;
                while (loop) {
                    Console.WriteLine("---------------Lookup-----------------");
                    Console.WriteLine("1. Lookup Available Countries");
                    Console.WriteLine("2. Lookup Available Currencies");
                    Console.WriteLine("3. Lookup Available Data Blocksizes");
                    Console.WriteLine("4. Lookup Available Data Throttles");
                    Console.WriteLine("5. Lookup Available Operators");
                    Console.WriteLine("6. Go to Main Menu");
                    Console.WriteLine("");
                    Console.Write("Lookup | Enter your choice: ");

                    String choice = Console.ReadLine();

                    if (IOTJson.Token == null) {
                        IOTJson.Authenticate();
                    }

                    if (choice.Trim().Equals("1")) {
                        IOTJson.GetRequest("country", "");
                    } else if (choice.Trim().Equals("2")) {
                        IOTJson.GetRequest("currency", "");
                    } else if (choice.Trim().Equals("3")) {
                        IOTJson.GetRequest("data_blocksize", "");
                    } else if (choice.Trim().Equals("4")) {
                        IOTJson.GetRequest("data_throttle", "");
                    } else if (choice.Trim().Equals("5")) {
                        IOTJson.GetRequest("operator", "");
                    } else if (choice.Trim().Equals("6")) {
                        loop = false;
                    }
                }
            } catch (AuthenticationException ex) {
                Console.WriteLine(ex.Message);
            }
        }

        private static String makeValue(String value, Boolean isInt)
        {
            String returnValue = null;
            if (!String.IsNullOrWhiteSpace(value)) {
                if (isInt)
                    returnValue = "{ \"id\":" + value + " }";
                else
                    returnValue = "\"" + value + "\"";
            }
            return returnValue;
        }
    }
}