Are there any examples for the REST API within Unity?
Stuff like adding, removing, or editing documents from NoSQL via JSON or other cool things?
What is the shortcode for? Does it work just like this documentation says? I just put in the request in there?
Also, stupid question, in Unity's Rest API window, it says username. Is that just my email I'm using? I can't find my username anywhere.
Best Answer
C
Customer Support
said
about 6 years ago
Editing the game-config from a client project would be a really bad idea. Especially since you can preform the same tasks using custom-log events with the benefit of sending that data over secure websocekts. You dont want to me sending your api-key and server-secret from the client when you dont need to.
However, an alternative could be to create your own REST api using one of your own custom callbacks. You can send the post-url using UnityWebRequests.
The REST api window in unity is only intended for testing, so the username and password are a player's username and password, not yours as the developer.
Editing the game-config from a client project would be a really bad idea. Especially since you can preform the same tasks using custom-log events with the benefit of sending that data over secure websocekts. You dont want to me sending your api-key and server-secret from the client when you dont need to.
However, an alternative could be to create your own REST api using one of your own custom callbacks. You can send the post-url using UnityWebRequests.
The REST api window in unity is only intended for testing, so the username and password are a player's username and password, not yours as the developer.
Hope that helps, Sean
O
One More Turn
said
about 6 years ago
thanks the reply
S
Sandesh Salunke
said
almost 6 years ago
var client = new RestClient(); client.BaseUrl = new Uri(GameSparksSettings.PortalUrl); client.Authenticator = new HttpBasicAuthenticator(strGSUSER, strGSPASS); client.Timeout = nTimeout;
var client = new RestClient(); client.BaseUrl = new Uri(GameSparksSettings.PortalUrl); client.Authenticator = new HttpBasicAuthenticator(strGSUSER, strGSPASS); client.Timeout = nTimeout;
One More Turn
Are there any examples for the REST API within Unity?
Stuff like adding, removing, or editing documents from NoSQL via JSON or other cool things?
What is the shortcode for? Does it work just like this documentation says? I just put in the request in there?
Also, stupid question, in Unity's Rest API window, it says username. Is that just my email I'm using? I can't find my username anywhere.
Especially since you can preform the same tasks using custom-log events with the benefit of sending that data over secure websocekts. You dont want to me sending your api-key and server-secret from the client when you dont need to.
However, an alternative could be to create your own REST api using one of your own custom callbacks.
You can send the post-url using UnityWebRequests.
The REST api window in unity is only intended for testing, so the username and password are a player's username and password, not yours as the developer.
Hope that helps,
Sean
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Especially since you can preform the same tasks using custom-log events with the benefit of sending that data over secure websocekts. You dont want to me sending your api-key and server-secret from the client when you dont need to.
However, an alternative could be to create your own REST api using one of your own custom callbacks.
You can send the post-url using UnityWebRequests.
The REST api window in unity is only intended for testing, so the username and password are a player's username and password, not yours as the developer.
Hope that helps,
Sean
One More Turn
thanks the reply
Sandesh Salunke
client.BaseUrl = new Uri(GameSparksSettings.PortalUrl);
client.Authenticator = new HttpBasicAuthenticator(strGSUSER, strGSPASS);
client.Timeout = nTimeout;
var request = new RestRequest();
request.Method = Method.POST;
request.RequestFormat = DataFormat.Json;
request.AlwaysMultipartFormData = true;
request.Timeout = nTimeout;
request.Resource = "rest/games/" + strGSAPIKEY + "/mongo/preview/" + strGSCOLLECTION + "/update";
string strGML = "";
Parameter jsonDOC = new Parameter();
jsonDOC.ContentType = "application/json";
jsonDOC.Type = ParameterType.GetOrPost;
jsonDOC.Name = "query";
jsonDOC.Value = "{\"BrandId\" : { \"$oid\" : \"" + strBRANDID + "\"}, \"GameId\" : { \"$oid\" : \"" + strGAMEID + "\"}}";
request.AddParameter(jsonDOC);
Parameter jsonDOC2 = new Parameter();
jsonDOC2.ContentType = "application/json";
jsonDOC2.Type = ParameterType.GetOrPost;
jsonDOC2.Name = "update";
jsonDOC2.Value = "{$set : {\"setlist." + strSETINDEX + ".GMLScript\":\"" + strGML + "\"}}";
request.AddParameter(jsonDOC2);
System.Console.WriteLine("START = " + DateTime.Now.ToLongDateString() + " @ " + DateTime.Now.ToLongTimeString());
IRestResponse response = client.Execute(request);
bool bEmptyResponse = (string.Compare(response.Content, "[]", true) == 0);
Sandesh Salunke
var client = new RestClient();
client.BaseUrl = new Uri(GameSparksSettings.PortalUrl);
client.Authenticator = new HttpBasicAuthenticator(strGSUSER, strGSPASS);
client.Timeout = nTimeout;
var request = new RestRequest();
request.Method = Method.POST;
request.RequestFormat = DataFormat.Json;
request.AlwaysMultipartFormData = true;
request.Timeout = nTimeout;
request.Resource = "rest/games/" + strGSAPIKEY + "/mongo/preview/" + strGSCOLLECTION + "/update";
string strGML = "";
Parameter jsonDOC = new Parameter();
jsonDOC.ContentType = "application/json";
jsonDOC.Type = ParameterType.GetOrPost;
jsonDOC.Name = "query";
jsonDOC.Value = "{\"BrandId\" : { \"$oid\" : \"" + strBRANDID + "\"}, \"GameId\" : { \"$oid\" : \"" + strGAMEID + "\"}}";
request.AddParameter(jsonDOC);
Parameter jsonDOC2 = new Parameter();
jsonDOC2.ContentType = "application/json";
jsonDOC2.Type = ParameterType.GetOrPost;
jsonDOC2.Name = "update";
jsonDOC2.Value = "{$set : {\"setlist." + strSETINDEX + ".GMLScript\":\"" + strGML + "\"}}";
request.AddParameter(jsonDOC2);
System.Console.WriteLine("START = " + DateTime.Now.ToLongDateString() + " @ " + DateTime.Now.ToLongTimeString());
IRestResponse response = client.Execute(request);
bool bEmptyResponse = (string.Compare(response.Content, "[]", true) == 0);
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics