Get proper response from curl command, but Forbidden from httpClient for Remote config

Hi All!

So my curl command works perfect form the command line, I’m getting the response with data
curl -H “Authorization: Basic ” https://services.api.unity.com/remote-config/v1/projects/{<PROJ>}/environments/{<ENV>}/configs

However, when I try to simulate this from Unity script, the response is the Forbidden error. Here’s what I do.

HttpClient httpClient = new();
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",_key);
string url = "https://services.api.unity.com/remote-config/v1/projects/{<PROJ>}/environments/{<ENV>}/configs";
HttpResponseMessage response = await httpClient.GetAsync(url);
Debug.Log(await response.Content.ReadAsStringAsync());

I think I tried everything :frowning: - but no luck, command line works, unity - doesnt :frowning:

Okay, I was stupid enough to include the curly brackets in the httpClient request. Removed the curly brackets, and everything worked. BUT. the curl command line command works WITH the curly brackets. I.e. the behaviour is definitely different.

Hi @vasaki,

What are you trying to achieve here, exactly? This looks like you’re trying to get a remote-config content without using the SDK. Is there something wrong with the SDK?

It will handle the web request for you, all you have to do is init the services…

What you are trying to do is possible but not really necessary, I strongly recommend you use the SDK.

It’s also hard to tell what the curl command was, you could just share the real URL (project ID and env ID), since not much can be done without the token anyway.

Cheers!