Particle.ParticleCloud.MakePostRequestAsync C# (CSharp) Method

MakePostRequestAsync() public method

Makes the post request asynchronous to the particle cloud
public MakePostRequestAsync ( String method ) : Task
method String The method to call
return Task
		public virtual async Task<RequestResponse> MakePostRequestAsync(String method, params KeyValuePair<String, String>[] arguments)
		{
			if (String.IsNullOrWhiteSpace(method))
			{
				throw new ArgumentNullException(nameof(method));
			}

			if (authResults == null)
			{
				throw new ParticleAuthenticationExeption(String.Format(RH.C.GetString("YouMusthAuthenticateBeforeCalling"), method));
			}


			client.DefaultRequestHeaders.Clear();
			client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", authResults.AccessToken);

			HttpResponseMessage response;
			if (arguments != null)
			{
				response = await client.PostAsync(method, new FormUrlEncodedContent(arguments));
			}
			else
			{
				response = await client.PostAsync(method, null);
			}
			var str = await response.Content.ReadAsStringAsync();
			RequestResponse rr = new RequestResponse();
			rr.StatusCode = response.StatusCode;
			rr.Response = await Task.Run(() => JToken.Parse(str));

			return rr;
		}