private void SetBaseHeaders() { httpHeaders = new HttpHeaders(); httpHeaders.AddOrUpdate(HttpHeaders.DreamFactoryApplicationHeader, "admin"); httpHeaders.AddOrUpdate(HttpHeaders.ContentTypeHeader, ContentSerializer.ContentType); httpHeaders.AddOrUpdate(HttpHeaders.AcceptHeader, ContentSerializer.ContentType); }
private void SetBaseHeaders(string applicationName, string applicationApiKey, string sessionId) { httpHeaders = new HttpHeaders(); httpHeaders.AddOrUpdate(HttpHeaders.FolderNameHeader, applicationName); httpHeaders.AddOrUpdate(HttpHeaders.DreamFactoryApiKeyHeader, applicationApiKey); httpHeaders.AddOrUpdate(HttpHeaders.ContentTypeHeader, ContentSerializer.ContentType); httpHeaders.AddOrUpdate(HttpHeaders.AcceptHeader, ContentSerializer.ContentType); if (!string.IsNullOrEmpty(sessionId)) { httpHeaders.AddOrUpdate(HttpHeaders.DreamFactorySessionTokenHeader, sessionId); } }
/// <inheritdoc /> public void SetApplicationName(string applicationName) { if (applicationName == null) { throw new ArgumentNullException("applicationName"); } httpHeaders.AddOrUpdate(HttpHeaders.FolderNameHeader, applicationName); }
public async Task <bool> RegisterAsync(Register register, bool login = false) { if (register == null) { throw new ArgumentNullException("register"); } var address = baseAddress.WithResource("register"); if (login) { address = address.WithParameter("login", true); } string content = contentSerializer.Serialize(register); IHttpRequest request = new HttpRequest(HttpMethod.Post, address.Build(), baseHeaders, content); IHttpResponse response = await httpFacade.RequestAsync(request); HttpUtils.ThrowOnBadStatus(response, contentSerializer); var success = new { success = false }; success = contentSerializer.Deserialize(response.Body, success); if (success.success && login) { Session session = await GetSessionAsync(); baseHeaders.AddOrUpdate(HttpHeaders.DreamFactorySessionTokenHeader, session.session_id); } return(success.success); }