Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public async Task GetItemsFromListByCaseNumber(string Case_Number)
- {
- byte[] responseString;
- try
- {
- string requestUrl = "/Case Document/items?expand=fields&filter=fields/CaseNumber eq '" + Case_Number + "'";
- await PostRequestToSharepoint(requestUrl, HttpMethod.Get);
- }
- catch (Exception ex)
- {
- }
- }
- public async Task<Dictionary<String, JsonValue>> PostRequestToSharepoint(string url, HttpMethod method)
- {
- byte[] responseString;
- Dictionary<String, JsonValue> list = new Dictionary<String, JsonValue>();
- try
- {
- string accessToken = await new ServiceAPIConnection().GetToken();
- string requestUrl = sharepointURL + "/sites/albaabtech.sharepoint.com:/sites/hha:/lists/Case Document/items?$select=AppointmentID&$filter=AppointmentID eq 'APPXID100000745'";
- // string requestUrl = sharepointURL + "/sites/albaabtech.sharepoint.com:/sites/hha:/lists" + url;
- HttpClient client = new HttpClient();
- HttpRequestMessage message = new HttpRequestMessage(method, requestUrl);
- message.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
- message.Headers.Authorization = new AuthenticationHeaderValue("Bearer",accessToken);
- HttpResponseMessage response = await client.SendAsync(message);
- if (response.IsSuccessStatusCode)
- {
- responseString = await response.Content.ReadAsByteArrayAsync();
- //Dictionary<String, IJsonValue> listDict = new Dictionary<string, IJsonValue>();
- //ParseJson(JsonObject.Parse(Encoding.UTF8.GetString(responseString, 0, responseString.Length)), listDict); //parse the json payload we got back
- //JsonArray lists = listDict["value"].GetArray(); // the "value" json structure contains the list metadata
- //if (lists.Count > 0)
- //{
- // foreach (IJsonValue item in lists)
- // {
- // try
- // {
- // ParseJson(item.GetObject(), list);
- // }
- // catch
- // {
- // Do no crash the app if we cannot parse the payload for a list
- // }
- // }
- //}
- }
- //else
- // responseString = "Error in response";
- }
- catch (Exception ex)
- {
- // responseString = "Exception: " + ex.Message;
- }
- return list;
- }
Add Comment
Please, Sign In to add comment