public static async Task <object> DoPost(string urlPath, PlayFabRequestCommon request, string authType, string authKey, Dictionary <string, string> extraHeaders, PlayFabApiSettings instanceSettings = null)
        {
            var settings = instanceSettings ?? PlayFabSettings.staticSettings;
            var fullPath = settings.GetFullUrl(urlPath);

            return(await _DoPost(fullPath, request, authType, authKey, extraHeaders, instanceSettings));
        }
        private static async Task <object> _DoPost(string fullPath, PlayFabRequestCommon request, string authType, string authKey, Dictionary <string, string> extraHeaders, PlayFabApiSettings instanceSettings = null)
        {
            var settings = instanceSettings ?? PlayFabSettings.staticSettings;
            var titleId  = settings.TitleId;

            if (titleId == null)
            {
                throw new PlayFabException(PlayFabExceptionCode.TitleNotSet, "You must set your titleId before making an api call");
            }
            var transport = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport);

            var headers = new Dictionary <string, string>();

            if (authType != null && authKey != null)
            {
                headers[authType] = authKey;
            }
            if (extraHeaders != null)
            {
                foreach (var extraHeader in extraHeaders)
                {
                    headers.Add(extraHeader.Key, extraHeader.Value);
                }
            }

            return(await transport.DoPost(fullPath, request, headers));
        }
示例#3
0
 public static async Task <object> DoPost(string urlPath, PlayFabRequestCommon request, string authType, string authKey)
 {
     if (PlayFabSettings.TitleId == null)
     {
         throw new Exception("You must set your titleId before making an api call");
     }
     return(await _http.DoPost(urlPath, request, authType, authKey));
 }
示例#4
0
 protected internal static void MakeApiCallWithFullUri <TResult>(string fullUri,
                                                                 PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback,
                                                                 Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null, bool allowQueueing = false, PlayFabAuthenticationContext authenticationContext = null, PlayFabApiSettings apiSettings = null)
     where TResult : PlayFabResultCommon
 {
     // This will not be called if environment file does not exist or does not contain property the debugging URI
     _MakeApiCall(null, fullUri, request, authType, resultCallback, errorCallback, customData, extraHeaders, allowQueueing, authenticationContext, apiSettings);
 }
示例#5
0
        protected internal static void MakeApiCall <TResult>(string apiEndpoint,
                                                             PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback,
                                                             Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null, bool allowQueueing = false, PlayFabAuthenticationContext authenticationContext = null, PlayFabApiSettings apiSettings = null)
            where TResult : PlayFabResultCommon
        {
            var fullUrl = apiSettings == null?PlayFabSettings.GetFullUrl(apiEndpoint, PlayFabSettings.RequestGetParams) : apiSettings.GetFullUrl(apiEndpoint, apiSettings.RequestGetParams);

            _MakeApiCall(apiEndpoint, fullUrl, request, authType, resultCallback, errorCallback, customData, extraHeaders, allowQueueing, authenticationContext, apiSettings);
        }
        /// <summary>
        /// Internal method for Make API Calls
        /// </summary>
        protected internal static void MakeApiCall <TResult>(string apiEndpoint,
                                                             PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback,
                                                             Action <PlayFabError> errorCallback, object customData = null, bool allowQueueing = false)
            where TResult : PlayFabResultCommon
        {
            InitializeHttp();
            SendEvent(apiEndpoint, request, null, ApiProcessingEventType.Pre);

            var reqContainer = new CallRequestContainer
            {
                ApiEndpoint   = apiEndpoint,
                FullUrl       = PlayFabSettings.GetFullUrl(apiEndpoint),
                CustomData    = customData,
                Payload       = Encoding.UTF8.GetBytes(JsonWrapper.SerializeObject(request, PlayFabUtil.ApiSerializerStrategy)),
                AuthKey       = authType,
                ApiRequest    = request,
                ErrorCallback = errorCallback,
            };

#if PLAYFAB_REQUEST_TIMING
            reqContainer.Timing.StartTimeUtc = DateTime.UtcNow;
            reqContainer.Timing.ApiEndpoint  = apiEndpoint;
#endif

            // These closures preserve the TResult generic information in a way that's safe for all the devices
            reqContainer.DeserializeResultJson = () =>
            {
                reqContainer.ApiResult = JsonWrapper.DeserializeObject <TResult>(reqContainer.JsonResponse, PlayFabUtil.ApiSerializerStrategy);
            };
            reqContainer.InvokeSuccessCallback = () =>
            {
                if (resultCallback != null)
                {
                    resultCallback((TResult)reqContainer.ApiResult);
                }
            };

            if (allowQueueing && _apiCallQueue != null && !_internalHttp.SessionStarted)
            {
                for (var i = _apiCallQueue.Count - 1; i >= 0; i--)
                {
                    if (_apiCallQueue[i].ApiEndpoint == apiEndpoint)
                    {
                        _apiCallQueue.RemoveAt(i);
                    }
                }
                _apiCallQueue.Add(reqContainer);
            }
            else
            {
                _internalHttp.MakeApiCall(reqContainer);
            }
        }
示例#7
0
 protected internal static void SendErrorEvent(PlayFabRequestCommon request, PlayFabError error)
 {
     if (PlayFabHttp.ApiProcessingErrorEventHandler == null)
     {
         return;
     }
     try
     {
         PlayFabHttp.ApiProcessingErrorEventHandler(request, error);
     }
     catch (Exception ex)
     {
     }
 }
示例#8
0
        protected internal static void SendErrorEvent(PlayFabRequestCommon request, PlayFabError error)
        {
            if (ApiProcessingErrorEventHandler == null)
            {
                return;
            }

            try {
                ApiProcessingErrorEventHandler(request, error);
            }
            catch (Exception e) {
                Debug.LogException(e);
            }
        }
示例#9
0
        protected internal static Task <TResult> MakeApiCallAsync <TResult>(string apiEndpoint,
                                                                            PlayFabRequestCommon request, AuthType authType, object customData = null, Dictionary <string, string> extraHeaders = null, PlayFabAuthenticationContext authenticationContext = null, PlayFabApiSettings apiSettings = null, IPlayFabInstanceApi instanceApi = null)
            where TResult : PlayFabResultCommon
        {
            TaskCompletionSource <TResult> tcs = new TaskCompletionSource <TResult>();

            apiSettings = apiSettings ?? PlayFabSettings.staticSettings;
            var fullUrl = apiSettings.GetFullUrl(apiEndpoint, apiSettings.RequestGetParams);

            _MakeApiCall(apiEndpoint, fullUrl, request, authType, (TResult a) => tcs.SetResult(a), error =>
            {
                Debug.LogError(error.GenerateErrorReport());
                tcs.SetException(error);
            }, customData, extraHeaders, false, authenticationContext, apiSettings, instanceApi);
            return(tcs.Task);
        }
示例#10
0
        private static void SendDeviceInfoToPlayFab()
        {
            if (PlayFabSettings.DisableDeviceInfo || !PlayFabDeviceUtil._gatherInfo)
            {
                return;
            }
            DeviceInfoRequest deviceInfoRequest = new DeviceInfoRequest
            {
                Info = new PlayFabDataGatherer()
            };
            string apiEndpoint                  = "/Client/ReportDeviceInfo";
            PlayFabRequestCommon request        = deviceInfoRequest;
            AuthType             authType       = AuthType.LoginSession;
            Action <EmptyResult> resultCallback = new Action <EmptyResult>(PlayFabDeviceUtil.OnGatherSuccess);

            PlayFabHttp.MakeApiCall(apiEndpoint, request, authType, resultCallback, new Action <PlayFabError>(PlayFabDeviceUtil.OnGatherFail), null, null, false);
        }
示例#11
0
 protected internal static void SendEvent(string apiEndpoint, PlayFabRequestCommon request,
                                          PlayFabResultCommon result, ApiProcessingEventType eventType)
 {
     if (ApiProcessingEventHandler == null)
     {
         return;
     }
     try {
         ApiProcessingEventHandler(new ApiProcessingEventArgs {
             ApiEndpoint = apiEndpoint,
             EventType   = eventType,
             Request     = request,
             Result      = result
         });
     }
     catch (Exception e) {
         Debug.LogException(e);
     }
 }
示例#12
0
 protected internal static void SendEvent(string apiEndpoint, PlayFabRequestCommon request, PlayFabResultCommon result, ApiProcessingEventType eventType)
 {
     if (PlayFabHttp.ApiProcessingEventHandler == null)
     {
         return;
     }
     try
     {
         PlayFabHttp.ApiProcessingEventHandler(new ApiProcessingEventArgs
         {
             ApiEndpoint = apiEndpoint,
             EventType   = eventType,
             Request     = request,
             Result      = result
         });
     }
     catch
     {
     }
 }
示例#13
0
 public static async Task <object> DoPostWithFullUri(string fullUriPath, PlayFabRequestCommon request, string authType, string authKey, Dictionary <string, string> extraHeaders, PlayFabApiSettings instanceSettings = null)
 {
     return(await _DoPost(fullUriPath, request, authType, authKey, extraHeaders, instanceSettings));
 }
示例#14
0
        protected internal static void MakeApiCall <TResult>(string apiEndpoint, PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null, bool allowQueueing = false) where TResult : PlayFabResultCommon
        {
            PlayFabHttp.InitializeHttp();
            PlayFabHttp.SendEvent(apiEndpoint, request, null, ApiProcessingEventType.Pre);
            CallRequestContainer reqContainer = new CallRequestContainer
            {
                ApiEndpoint    = apiEndpoint,
                FullUrl        = PlayFabSettings.GetFullUrl(apiEndpoint),
                CustomData     = customData,
                Payload        = Encoding.UTF8.GetBytes(JsonWrapper.SerializeObject(request)),
                ApiRequest     = request,
                ErrorCallback  = errorCallback,
                RequestHeaders = (extraHeaders ?? new Dictionary <string, string>())
            };

            foreach (KeyValuePair <string, string> keyValuePair in PlayFabHttp.GlobalHeaderInjection)
            {
                if (!reqContainer.RequestHeaders.ContainsKey(keyValuePair.Key))
                {
                    reqContainer.RequestHeaders[keyValuePair.Key] = keyValuePair.Value;
                }
            }
            reqContainer.RequestHeaders["X-ReportErrorAsSuccess"] = "true";
            reqContainer.RequestHeaders["X-PlayFabSDK"]           = "UnitySDK-2.39.180409";
            if (authType != AuthType.LoginSession)
            {
                if (authType == AuthType.EntityToken)
                {
                    reqContainer.RequestHeaders["X-EntityToken"] = PlayFabHttp._internalHttp.EntityToken;
                }
            }
            else
            {
                reqContainer.RequestHeaders["X-Authorization"] = PlayFabHttp._internalHttp.AuthKey;
            }
            reqContainer.DeserializeResultJson = delegate()
            {
                reqContainer.ApiResult = JsonWrapper.DeserializeObject <TResult>(reqContainer.JsonResponse);
            };
            reqContainer.InvokeSuccessCallback = delegate()
            {
                if (resultCallback != null)
                {
                    resultCallback((TResult)((object)reqContainer.ApiResult));
                }
            };
            if (allowQueueing && PlayFabHttp._apiCallQueue != null && !PlayFabHttp._internalHttp.SessionStarted)
            {
                for (int i = PlayFabHttp._apiCallQueue.Count - 1; i >= 0; i--)
                {
                    if (PlayFabHttp._apiCallQueue[i].ApiEndpoint == apiEndpoint)
                    {
                        PlayFabHttp._apiCallQueue.RemoveAt(i);
                    }
                }
                PlayFabHttp._apiCallQueue.Add(reqContainer);
            }
            else
            {
                PlayFabHttp._internalHttp.MakeApiCall(reqContainer);
            }
        }
示例#15
0
        /// <summary>
        /// Internal method for Make API Calls
        /// </summary>
        private static void _MakeApiCall <TResult>(string apiEndpoint, string fullUrl,
                                                   PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback,
                                                   Action <PlayFabError> errorCallback, object customData, Dictionary <string, string> extraHeaders, bool allowQueueing, PlayFabAuthenticationContext authenticationContext, PlayFabApiSettings apiSettings, IPlayFabInstanceApi instanceApi)
            where TResult : PlayFabResultCommon
        {
            InitializeHttp();
            SendEvent(apiEndpoint, request, null, ApiProcessingEventType.Pre);

            var serializer   = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer);
            var reqContainer = new CallRequestContainer
            {
                ApiEndpoint    = apiEndpoint,
                FullUrl        = fullUrl,
                settings       = apiSettings,
                context        = authenticationContext,
                CustomData     = customData,
                Payload        = Encoding.UTF8.GetBytes(serializer.SerializeObject(request)),
                ApiRequest     = request,
                ErrorCallback  = errorCallback,
                RequestHeaders = extraHeaders ?? new Dictionary <string, string>(), // Use any headers provided by the customer
                instanceApi    = instanceApi
            };

            // Append any additional headers
            foreach (var pair in GlobalHeaderInjection)
            {
                if (!reqContainer.RequestHeaders.ContainsKey(pair.Key))
                {
                    reqContainer.RequestHeaders[pair.Key] = pair.Value;
                }
            }

#if PLAYFAB_REQUEST_TIMING
            reqContainer.Timing.StartTimeUtc = DateTime.UtcNow;
            reqContainer.Timing.ApiEndpoint  = apiEndpoint;
#endif

            // Add PlayFab Headers
            var transport = PluginManager.GetPlugin <ITransportPlugin>(PluginContract.PlayFab_Transport);
            reqContainer.RequestHeaders["X-ReportErrorAsSuccess"] = "true";                        // Makes processing PlayFab errors a little easier
            reqContainer.RequestHeaders["X-PlayFabSDK"]           = PlayFabSettings.VersionString; // Tell PlayFab which SDK this is
            switch (authType)
            {
#if ENABLE_PLAYFABSERVER_API || ENABLE_PLAYFABADMIN_API || UNITY_EDITOR
            case AuthType.DevSecretKey:
                if (apiSettings.DeveloperSecretKey == null)
                {
                    throw new PlayFabException(PlayFabExceptionCode.DeveloperKeyNotSet, "DeveloperSecretKey is not found in Request, Server Instance or PlayFabSettings");
                }
                reqContainer.RequestHeaders["X-SecretKey"] = apiSettings.DeveloperSecretKey; break;
#endif
#if !DISABLE_PLAYFABCLIENT_API
            case AuthType.LoginSession:
                if (authenticationContext != null)
                {
                    reqContainer.RequestHeaders["X-Authorization"] = authenticationContext.ClientSessionTicket;
                }
                break;
#endif
#if !DISABLE_PLAYFABENTITY_API
            case AuthType.EntityToken:
                if (authenticationContext != null)
                {
                    reqContainer.RequestHeaders["X-EntityToken"] = authenticationContext.EntityToken;
                }
                break;
#endif
            }

            // These closures preserve the TResult generic information in a way that's safe for all the devices
            reqContainer.DeserializeResultJson = () =>
            {
                reqContainer.ApiResult = serializer.DeserializeObject <TResult>(reqContainer.JsonResponse);
            };
            reqContainer.InvokeSuccessCallback = () =>
            {
                if (resultCallback != null)
                {
                    resultCallback((TResult)reqContainer.ApiResult);
                }
            };

            if (allowQueueing && _apiCallQueue != null)
            {
                for (var i = _apiCallQueue.Count - 1; i >= 0; i--)
                {
                    if (_apiCallQueue[i].ApiEndpoint == apiEndpoint)
                    {
                        _apiCallQueue.RemoveAt(i);
                    }
                }
                _apiCallQueue.Add(reqContainer);
            }
            else
            {
                transport.MakeApiCall(reqContainer);
            }
        }
        /// <summary>
        /// Internal method for Make API Calls
        /// </summary>
        protected internal static void MakeApiCall <TResult>(string apiEndpoint,
                                                             PlayFabRequestCommon request, AuthType authType, Action <TResult> resultCallback,
                                                             Action <PlayFabError> errorCallback, object customData = null, Dictionary <string, string> extraHeaders = null, bool allowQueueing = false)
            where TResult : PlayFabResultCommon
        {
            InitializeHttp();
            SendEvent(apiEndpoint, request, null, ApiProcessingEventType.Pre);

            var reqContainer = new CallRequestContainer
            {
                ApiEndpoint    = apiEndpoint,
                FullUrl        = PlayFabSettings.GetFullUrl(apiEndpoint),
                CustomData     = customData,
                Payload        = Encoding.UTF8.GetBytes(JsonWrapper.SerializeObject(request)),
                ApiRequest     = request,
                ErrorCallback  = errorCallback,
                RequestHeaders = extraHeaders ?? new Dictionary <string, string>() // Use any headers provided by the customer
            };

            // Append any additional headers
            foreach (var pair in GlobalHeaderInjection)
            {
                if (!reqContainer.RequestHeaders.ContainsKey(pair.Key))
                {
                    reqContainer.RequestHeaders[pair.Key] = pair.Value;
                }
            }

#if PLAYFAB_REQUEST_TIMING
            reqContainer.Timing.StartTimeUtc = DateTime.UtcNow;
            reqContainer.Timing.ApiEndpoint  = apiEndpoint;
#endif

            // Add PlayFab Headers
            reqContainer.RequestHeaders["X-ReportErrorAsSuccess"] = "true";                        // Makes processing PlayFab errors a little easier
            reqContainer.RequestHeaders["X-PlayFabSDK"]           = PlayFabSettings.VersionString; // Tell PlayFab which SDK this is
            switch (authType)
            {
#if ENABLE_PLAYFABSERVER_API || ENABLE_PLAYFABADMIN_API
            case AuthType.DevSecretKey: reqContainer.RequestHeaders["X-SecretKey"] = PlayFabSettings.DeveloperSecretKey; break;
#endif
            case AuthType.LoginSession: reqContainer.RequestHeaders["X-Authorization"] = _internalHttp.AuthKey; break;

            case AuthType.EntityToken: reqContainer.RequestHeaders["X-EntityToken"] = _internalHttp.EntityToken; break;
            }

            // These closures preserve the TResult generic information in a way that's safe for all the devices
            reqContainer.DeserializeResultJson = () =>
            {
                reqContainer.ApiResult = JsonWrapper.DeserializeObject <TResult>(reqContainer.JsonResponse);
            };
            reqContainer.InvokeSuccessCallback = () =>
            {
                if (resultCallback != null)
                {
                    resultCallback((TResult)reqContainer.ApiResult);
                }
            };

            if (allowQueueing && _apiCallQueue != null && !_internalHttp.SessionStarted)
            {
                for (var i = _apiCallQueue.Count - 1; i >= 0; i--)
                {
                    if (_apiCallQueue[i].ApiEndpoint == apiEndpoint)
                    {
                        _apiCallQueue.RemoveAt(i);
                    }
                }
                _apiCallQueue.Add(reqContainer);
            }
            else
            {
                _internalHttp.MakeApiCall(reqContainer);
            }
        }
 private static void SharedError_Global(PlayFabRequestCommon request, PlayFabError error)
 {
     Callbacks.Add("SharedError_Global");
     throw new Exception("Non-PlayFab callback error");
 }
示例#18
0
        public async Task <object> DoPost(string urlPath, PlayFabRequestCommon request, string authType, string authKey, Dictionary <string, string> extraHeaders)
        {
            var    fullUrl = PlayFabSettings.GetFullUrl(urlPath);
            string bodyString;

            if (request == null)
            {
                bodyString = "{}";
            }
            else
            {
                bodyString = JsonWrapper.SerializeObject(request);
            }

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, new Uri(fullUrl));

            requestMessage.Content = new HttpStringContent(bodyString, Windows.Storage.Streams.UnicodeEncoding.Utf8, "application/json");
            if (authType != null)
            {
                requestMessage.Headers.Add(new KeyValuePair <string, string>(authType, authKey));
            }
            requestMessage.Headers.Add(new KeyValuePair <string, string>("X-PlayFabSDK", PlayFabSettings.SdkVersionString));
            if (extraHeaders != null)
            {
                foreach (var headerPair in extraHeaders)
                {
                    requestMessage.Headers.Add(headerPair);
                }
            }

            HttpResponseMessage httpResponse;
            string httpResponseString;

            try
            {
                httpResponse = await _client.SendRequestAsync(requestMessage);

                httpResponseString = await httpResponse.Content.ReadAsStringAsync();
            }
            catch (Exception e)
            {
                return(new PlayFabError
                {
                    Error = PlayFabErrorCode.ConnectionError,
                    ErrorMessage = e.Message
                });
            }

            if (!httpResponse.IsSuccessStatusCode)
            {
                var error = new PlayFabError();

                if (string.IsNullOrEmpty(httpResponseString) || httpResponse.StatusCode == HttpStatusCode.NotFound)
                {
                    error.HttpCode   = (int)httpResponse.StatusCode;
                    error.HttpStatus = httpResponse.StatusCode.ToString();
                    return(error);
                }

                PlayFabJsonError errorResult;
                try
                {
                    errorResult = JsonWrapper.DeserializeObject <PlayFabJsonError>(httpResponseString);
                }
                catch (Exception e)
                {
                    error.HttpCode     = (int)httpResponse.StatusCode;
                    error.HttpStatus   = httpResponse.StatusCode.ToString();
                    error.Error        = PlayFabErrorCode.JsonParseError;
                    error.ErrorMessage = e.Message;
                    return(error);
                }

                error.HttpCode     = errorResult.code;
                error.HttpStatus   = errorResult.status;
                error.Error        = (PlayFabErrorCode)errorResult.errorCode;
                error.ErrorMessage = errorResult.errorMessage;
                error.ErrorDetails = errorResult.errorDetails;
                return(error);
            }

            if (string.IsNullOrEmpty(httpResponseString))
            {
                return(new PlayFabError
                {
                    Error = PlayFabErrorCode.Unknown,
                    ErrorMessage = "Internal server error"
                });
            }

            return(httpResponseString);
        }
示例#19
0
        public async Task <object> DoPost(string urlPath, PlayFabRequestCommon request, string authType, string authKey, Dictionary <string, string> extraHeaders)
        {
            var    fullUrl = PlayFabSettings.GetFullUrl(urlPath);
            string bodyString;

            if (request == null)
            {
                bodyString = "{}";
            }
            else
            {
                bodyString = JsonWrapper.SerializeObject(request);
            }

            var client = new HttpClient();
            HttpResponseMessage httpResponse;
            string httpResponseString;

            using (var postBody = new ByteArrayContent(Encoding.UTF8.GetBytes(bodyString)))
            {
                postBody.Headers.Add("Content-Type", "application/json");
                if (authType != null)
                {
                    postBody.Headers.Add(authType, authKey);
                }
                postBody.Headers.Add("X-PlayFabSDK", PlayFabSettings.SdkVersionString);
                if (extraHeaders != null)
                {
                    foreach (var headerPair in extraHeaders)
                    {
                        postBody.Headers.Add(headerPair.Key, headerPair.Value);
                    }
                }

                try
                {
                    httpResponse = await client.PostAsync(fullUrl, postBody);

                    httpResponseString = await httpResponse.Content.ReadAsStringAsync();
                }
                catch (HttpRequestException e)
                {
                    return(new PlayFabError
                    {
                        Error = PlayFabErrorCode.ConnectionError,
                        ErrorMessage = e.InnerException.Message
                    });
                }
                catch (Exception e)
                {
                    return(new PlayFabError
                    {
                        Error = PlayFabErrorCode.ConnectionError,
                        ErrorMessage = e.Message
                    });
                }
            }

            if (!httpResponse.IsSuccessStatusCode)
            {
                var error = new PlayFabError();

                if (string.IsNullOrEmpty(httpResponseString) || httpResponse.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    error.HttpCode   = (int)httpResponse.StatusCode;
                    error.HttpStatus = httpResponse.StatusCode.ToString();
                    return(error);
                }

                PlayFabJsonError errorResult;
                try
                {
                    errorResult = JsonWrapper.DeserializeObject <PlayFabJsonError>(httpResponseString);
                }
                catch (Exception e)
                {
                    error.HttpCode     = (int)httpResponse.StatusCode;
                    error.HttpStatus   = httpResponse.StatusCode.ToString();
                    error.Error        = PlayFabErrorCode.JsonParseError;
                    error.ErrorMessage = e.Message;
                    return(error);
                }

                error.HttpCode     = errorResult.code;
                error.HttpStatus   = errorResult.status;
                error.Error        = (PlayFabErrorCode)errorResult.errorCode;
                error.ErrorMessage = errorResult.errorMessage;
                error.ErrorDetails = errorResult.errorDetails;
                return(error);
            }

            if (string.IsNullOrEmpty(httpResponseString))
            {
                return(new PlayFabError
                {
                    Error = PlayFabErrorCode.Unknown,
                    ErrorMessage = "Internal server error"
                });
            }

            return(httpResponseString);
        }