AppHarbor.AppHarborClient.CreateHostname C# (CSharp) Method

CreateHostname() public method

public CreateHostname ( string applicationSlug, string hostName ) : CreateResult
applicationSlug string
hostName string
return CreateResult
		public CreateResult CreateHostname(string applicationSlug, string hostName)
		{
			CheckArgumentNull("applicationSlug", applicationSlug);
			CheckArgumentNull("hostName", hostName);

			var request = new RestRequest(Method.POST);
			request.RequestFormat = DataFormat.Json;
			request.Resource = "applications/{applicationSlug}/hostnames";
			request.AddParameter("applicationSlug", applicationSlug, ParameterType.UrlSegment);
			request.AddBody(new
			{
				value = hostName,
			});
			return ExecuteCreate(request);
		}

Usage Example

Example #1
0
        public void CreateHostname(string applicationId, string hostname)
        {
            var result = _api.CreateHostname(applicationId, hostname);

            try
            {
                HandleCreateResult("hostname", hostname, result.Status);
            }
            catch (ApiException)
            {
                //We currently have no way of determining if the ApiException was caused by missing credit card or another API error.
                throw new ApiException("The problem may be that we do not have a credit card on file for the application owner");
            }
        }