public IdentityProviderDto Create(ServerDto server, string tenant, IdentityProviderDto provider, Token token) { var schemaSerialized = SerializeSchema(provider.Schema); var attributeSerailized = SerializeAttributes(provider.AttributesMap, "attributesMap"); provider.Schema = null; provider.AttributesMap = null; tenant = Uri.EscapeDataString(tenant); var url = string.Format(_serviceConfigManager.GetIdentityProvidersEndPoint(), server.Protocol, server.ServerName, server.Port, tenant); var dto = typeof(IdentityProviderDto).Assembly; var json = JsonConvert.Serialize(provider, "root", dto.GetTypes(), true); json = SerializationJsonHelper.Cleanup(json); json = json.Substring(0, json.Length - 1); var attributeString = "\"attributesMap\":null,"; if (json.Contains(attributeString)) { json = json.Replace(attributeString, attributeSerailized + (string.IsNullOrEmpty(attributeSerailized)? string.Empty : ",")); } else { json += attributeSerailized; } var schemaString = "\"schema\":null,"; if (json.Contains(schemaString)) { json = json.Replace(schemaString, schemaSerialized + (string.IsNullOrEmpty(schemaSerialized)? string.Empty : ",")); } else { json += schemaSerialized; } json += "}"; ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); }; var requestConfig = new RequestSettings { Method = HttpMethod.Post }; var headers = ServiceHelper.AddHeaders(ServiceConstants.JsonContentType); json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json; var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json); return(JsonConvert.JsonDeserialize <IdentityProviderDto>(response)); }