RestClient
RestClient copied to clipboard
Post not working on WebGL compilation
Hello.
I have a post implementation wich works correctly from que unity editor, but when I build and run the project in WebGL, I receive a message : "Proyecto26.RequestException: Unknown Error" but I can't figure out wich is the reason.
Code fragment:
public static void SaveDatabase(){ RestClient.Post("https://my-project.firebaseio.com/users/.json", GameInfo.info) .Then(response => Debug.Log("Información del jugador guardada exitosamente: " + JsonUtility.ToJson(response, true)) ) .Catch(error => { Debug.LogError("Error guardando la información del jugador: "+ error.Message); } ); }
GameInfo.info is a DTO object with a serialization toString method wich converts the content to json.
The error logged from the catch:
Please, let me know wich extra information could be required to resolve this issue. Any help will be very appreciated.
Hi,
I have the same problem, requesting a GET<Models.ResponseGallery> it returns "UNKNOWN ERROR" which doesn't tell anything usefull to search for solutions :-)
It only fails when called from WEBGL, from unity editor or standalone/mobile it works fine
[Serializable]
public class Media
{
public int id;
public int story_id;
public string stage;
public string title;
public string media_type;
public string media_file;
public bool force_page;
public DateTime created;
public DateTime modified;
}
[Serializable]
public class ResponseGallery : Response
{
public Media[] data;
}
Request: { "Uri": "https://SERVERADDRESSHIDDEN/api/stories/10/gallery/", "Method": "GET", "Body": { "stage": "", "text": "" }, "BodyString": null, "BodyRaw": null, "Timeout": null, "ContentType": null, "Retries": 0, "RetrySecondsDelay": 0.0, "RetryCallbackOnlyOnNetworkErrors": true, "RetryCallback": null, "ProgressCallback": null, "EnableDebug": true, "UseHttpContinue": true, "RedirectLimit": null, "IgnoreHttpException": false, "FormData": null, "SimpleForm": null, "FormSections": null, "CertificateHandler": null, "UploadHandler": null, "DownloadHandler": null, "Headers": [ { "Key": "Authorization", "Value": "Bearer lWnJvilJmJUuru9gzlaOznnDAuFoze" } ], "Params": [], "ParseResponseBody": true, "UploadProgress": 0.0, "UploadedBytes": 0, "DownloadProgress": 0.0, "DownloadedBytes": 0, "IsAborted": false, "DefaultContentType": true }
Could you send stacktrace of the error? Maybe it can help
You can turn it on in Project Settings > Player > Publishing Settings > Enable Exceptions.
For anyone wondering if this is an issue with this asset, it is not. I created a new project in Unity 2021.3.27f1, using RestClient v2.6.2, and could run the GET and POST commands from the Demo scene without any issues.
Get Test
Post Test
Would recommend closing this issue, as it doesn't seem specific to this asset or WebGL.