I have created some javascript API endpoints with Cloud-Code. But I can’t figure out how to get the URL for each of those environment enpoints? From what I can tell, there is only 1 url… which doesn’t make sense. For example, the docs say this is how to get the url:
https://cloud-code.services.api.unity.com/v1/projects/<PROJECT_ID>/scripts/<SCRIPT_NAME>
Shouldn’t there be the environment name somehwere in t he URL??
Hi there.
I am also new to Cloud Code, but I could offer some advice.
To call a JS function, you need to do roughly this:
Dictionary<string, object> arguments = new Dictionary<string, object> { { "nameOfParameter1", "value" } } // Etc
var returnedValue = await CloudCodeService.Instance.CallEndpointAsync<returnType>("nameOfScript", arguments); // Return type can be a string, bool, int, etc.
Remember to add “using Unity.Services.CloudCode” at the top of your script, and install the Cloud Code package.
Hope this helps!
Hi @alan_negrete
The environment is not part of the URL. The environment is set when you “sign in” using the authentication service. The authentication service returns a bearer token that is used to authenticate the Cloud Code request and this token contains the environment ID.
Hope that helps clarifies things!